diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93f2c0fea..a5c6e2b79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,14 +65,18 @@ jobs: run: ./scripts/build - name: Get GitHub OIDC Token - if: github.repository == 'stainless-sdks/orb-java' + if: |- + github.repository == 'stainless-sdks/orb-java' && + !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v6 + uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Build and upload Maven artifacts - if: github.repository == 'stainless-sdks/orb-java' + if: |- + github.repository == 'stainless-sdks/orb-java' && + !startsWith(github.ref, 'refs/heads/stl/') env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index eb4e0dba7..caf148712 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.10.0" + ".": "1.11.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 666bff36b..438843fd3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 126 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c131de17773b450eb1ec03ca001f94d3777e35347234869a7efee083003e1513.yml -openapi_spec_hash: 5d2d4a3a9ada1c381efb318b6897994d -config_hash: bcf82bddb691f6be773ac6cae8c03b9a +configured_endpoints: 139 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d6a851f21804170f796637f1911c3382f1c57f5ed6b9b77cd7d0c6f74c06e174.yml +openapi_spec_hash: 82df33badf54d0c7087a61145d379f58 +config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2985ce5a0..f487c6bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,61 @@ # Changelog +## 1.11.0 (2026-03-07) + +Full Changelog: [v1.10.0...v1.11.0](https://github.com/orbcorp/orb-java/compare/v1.10.0...v1.11.0) + +### Features + +* **api:** api update ([037dbcd](https://github.com/orbcorp/orb-java/commit/037dbcde5fbff819b3a65b43bdc92332a88d96e5)) +* **api:** api update ([014ce03](https://github.com/orbcorp/orb-java/commit/014ce038155006c8874869d82da451b427b5a177)) +* **api:** api update ([4ed5e39](https://github.com/orbcorp/orb-java/commit/4ed5e399e2aeb4ba507314f37ebe510a7f4dcecf)) +* **api:** api update ([522cf9b](https://github.com/orbcorp/orb-java/commit/522cf9bee689650a217f54f12d93f1c548994fa0)) +* **api:** api update ([7661c8c](https://github.com/orbcorp/orb-java/commit/7661c8c5892a01032cf4b24a74b309a2eac77f0c)) +* **api:** api update ([ededc4d](https://github.com/orbcorp/orb-java/commit/ededc4dcf7a0dcbe132f60e4e06b7c0b3c538caa)) +* **api:** api update ([3b82472](https://github.com/orbcorp/orb-java/commit/3b8247255097a5250b47059ca568429a26e0f285)) +* **api:** api update ([c310e36](https://github.com/orbcorp/orb-java/commit/c310e36ffe22fafdd5ba9a00728e7816a8d0e1e6)) +* **api:** api update ([a80ec0b](https://github.com/orbcorp/orb-java/commit/a80ec0b34dabf9595dbae9dfc4b4ed6c914cf5d2)) +* **api:** api update ([69429b9](https://github.com/orbcorp/orb-java/commit/69429b99a2aa15ce52ebd45f7a2a531395f3dc94)) +* **api:** api update ([49d56e2](https://github.com/orbcorp/orb-java/commit/49d56e2d1ef966ebf6ad4508c81b43a19e7cf9c5)) +* **api:** api update ([1e5f897](https://github.com/orbcorp/orb-java/commit/1e5f8972d4dd8c4c955e8980b0c83901a2594bd6)) +* **api:** api update ([eaca79d](https://github.com/orbcorp/orb-java/commit/eaca79da23a8cad0430abcb0319c8a37a5bbfc2a)) +* **api:** manual updates ([5ba9c33](https://github.com/orbcorp/orb-java/commit/5ba9c33bba4f76344046e7cd93946fe96befaf34)) +* **client:** add connection pooling option ([21b4047](https://github.com/orbcorp/orb-java/commit/21b4047e592f1d92782f6aacba9ba0f4d8d893d2)) +* **client:** add more convenience service method overloads ([f56884d](https://github.com/orbcorp/orb-java/commit/f56884dcd6437584dabd311bf0583c6145515e60)) +* **client:** send `X-Stainless-Kotlin-Version` header ([10357a9](https://github.com/orbcorp/orb-java/commit/10357a946d98ffd0cb26409f81af477b4c4638b2)) + + +### Bug Fixes + +* **client:** preserve time zone in lenient date-time parsing ([928bfae](https://github.com/orbcorp/orb-java/commit/928bfae14d9e8353f052404bf80873f1bd60d167)) +* fix request delays for retrying to be more respectful of high requested delays ([185d18d](https://github.com/orbcorp/orb-java/commit/185d18dd791129bdbcf9c7c0fe12cdeb34474045)) + + +### Chores + +* **ci:** skip uploading artifacts on stainless-internal branches ([2b236e9](https://github.com/orbcorp/orb-java/commit/2b236e90a64e621b2f772208c4048ccb1f26c066)) +* **ci:** upgrade `actions/github-script` ([7850067](https://github.com/orbcorp/orb-java/commit/7850067ac12719de79ff00ada02962f035782791)) +* **docs:** add missing descriptions ([d101825](https://github.com/orbcorp/orb-java/commit/d101825fc5db427bb9d36c6b82154919eea85103)) +* drop apache dependency ([edcdb51](https://github.com/orbcorp/orb-java/commit/edcdb514ff66cba287aab7ec5dec282078abb45f)) +* **internal:** allow passing args to `./scripts/test` ([ffbc747](https://github.com/orbcorp/orb-java/commit/ffbc7473823b4ea0ccd27b9cfb85f8a5c165bb47)) +* **internal:** bump palantir-java-format ([82f17f8](https://github.com/orbcorp/orb-java/commit/82f17f8f9081527292cc9ca2bc150d10b2b9dfc1)) +* **internal:** codegen related update ([489bdd6](https://github.com/orbcorp/orb-java/commit/489bdd632da69ee3bafce9d5364861821f235c2b)) +* **internal:** codegen related update ([b8b2251](https://github.com/orbcorp/orb-java/commit/b8b2251ef940a4d3a5276a9287bfc628fcc7fa2b)) +* **internal:** codegen related update ([46abca4](https://github.com/orbcorp/orb-java/commit/46abca478b99884a07ac874f56f5ab7f615d9162)) +* **internal:** correct cache invalidation for `SKIP_MOCK_TESTS` ([4a49c05](https://github.com/orbcorp/orb-java/commit/4a49c05fd112adb44adebff7481d4076ede46058)) +* **internal:** expand imports ([c1195af](https://github.com/orbcorp/orb-java/commit/c1195afe5fc1798dbfd9c8c183501d1e4f33db75)) +* **internal:** make `OkHttp` constructor internal ([05a1acc](https://github.com/orbcorp/orb-java/commit/05a1acc5dd4128fe698db34626ebaaed97ad17f6)) +* **internal:** update `TestServerExtension` comment ([3447469](https://github.com/orbcorp/orb-java/commit/34474693bac76cf4855636d09bac7001108f2ccc)) +* **internal:** update maven repo doc to include authentication ([9aa3e27](https://github.com/orbcorp/orb-java/commit/9aa3e2745cf3794784ee229af579142c6d560182)) +* **internal:** upgrade AssertJ ([719f036](https://github.com/orbcorp/orb-java/commit/719f036e81d72bf5c80a3e53de1e6fcdee49f15e)) +* make `Properties` more resilient to `null` ([39c553f](https://github.com/orbcorp/orb-java/commit/39c553f7b878162f7affd567e9c0450d1411e653)) +* **test:** do not count install time for mock server timeout ([efdd6eb](https://github.com/orbcorp/orb-java/commit/efdd6ebf4a150e21f6edc283f5cd8f91ed049b12)) + + +### Documentation + +* add comment for arbitrary value fields ([e2f42d1](https://github.com/orbcorp/orb-java/commit/e2f42d1f5d5b951c50798e943a64e14ff134b4f2)) + ## 1.10.0 (2026-01-17) Full Changelog: [v1.9.0...v1.10.0](https://github.com/orbcorp/orb-java/compare/v1.9.0...v1.10.0) diff --git a/README.md b/README.md index be99484ce..3a3cba045 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.10.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.11.0) @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho ### Gradle ```kotlin -implementation("com.withorb.api:orb-java:1.10.0") +implementation("com.withorb.api:orb-java:1.11.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:1.10.0") com.withorb.api orb-java - 1.10.0 + 1.11.0 ``` @@ -457,6 +457,25 @@ OrbClient client = OrbOkHttpClient.builder() .build(); ``` +### Connection pooling + +To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: + +```java +import com.withorb.api.client.OrbClient; +import com.withorb.api.client.okhttp.OrbOkHttpClient; +import java.time.Duration; + +OrbClient client = OrbOkHttpClient.builder() + .fromEnv() + // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa. + .maxIdleConnections(10) + .keepAliveDuration(Duration.ofMinutes(2)) + .build(); +``` + +If both options are unset, OkHttp's default connection pool settings are used. + ### HTTPS > [!NOTE] diff --git a/build.gradle.kts b/build.gradle.kts index 8e1585b2b..81989492b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ allprojects { group = "com.withorb.api" - version = "1.10.0" // x-release-please-version + version = "1.11.0" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/orb.java.gradle.kts b/buildSrc/src/main/kotlin/orb.java.gradle.kts index 70fc33f41..8f4f902a6 100644 --- a/buildSrc/src/main/kotlin/orb.java.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.java.gradle.kts @@ -45,7 +45,7 @@ tasks.withType().configureEach { val palantir by configurations.creating dependencies { - palantir("com.palantir.javaformat:palantir-java-format:2.73.0") + palantir("com.palantir.javaformat:palantir-java-format:2.89.0") } fun registerPalantir( diff --git a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts index b908b3bed..78bb0bbc3 100644 --- a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts @@ -33,6 +33,9 @@ kotlin { tasks.withType().configureEach { systemProperty("junit.jupiter.execution.parallel.enabled", true) systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") + + // `SKIP_MOCK_TESTS` affects which tests run so it must be added as input for proper cache invalidation. + inputs.property("skipMockTests", System.getenv("SKIP_MOCK_TESTS")).optional(true) } val ktfmt by configurations.creating diff --git a/examples/.keep b/examples/.keep deleted file mode 100644 index d8c73e937..000000000 --- a/examples/.keep +++ /dev/null @@ -1,4 +0,0 @@ -File generated from our OpenAPI spec by Stainless. - -This directory can be used to store example files demonstrating usage of this SDK. -It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/orb-java-client-okhttp/build.gradle.kts b/orb-java-client-okhttp/build.gradle.kts index 856cade40..e2241172b 100644 --- a/orb-java-client-okhttp/build.gradle.kts +++ b/orb-java-client-okhttp/build.gradle.kts @@ -10,6 +10,6 @@ dependencies { implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") testImplementation(kotlin("test")) - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt index 4d54698c3..ebfa6f879 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt +++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt @@ -16,11 +16,13 @@ import java.time.Duration import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture import java.util.concurrent.ExecutorService +import java.util.concurrent.TimeUnit import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback +import okhttp3.ConnectionPool import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType @@ -33,7 +35,7 @@ import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink class OkHttpClient -private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { +internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) @@ -200,6 +202,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null @@ -211,6 +215,28 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + /** + * Sets the maximum number of idle connections kept by the underlying [ConnectionPool]. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Sets the keep-alive duration for idle connections in the underlying [ConnectionPool]. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { this.dispatcherExecutorService = dispatcherExecutorService } @@ -240,6 +266,22 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien .apply { dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val maxIdleConnections = maxIdleConnections + val keepAliveDuration = keepAliveDuration + if (maxIdleConnections != null && keepAliveDuration != null) { + connectionPool( + ConnectionPool( + maxIdleConnections, + keepAliveDuration.toNanos(), + TimeUnit.NANOSECONDS, + ) + ) + } else { + check((maxIdleConnections != null) == (keepAliveDuration != null)) { + "Both or none of `maxIdleConnections` and `keepAliveDuration` must be set, but only one was set" + } + } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt index efc83cf9b..edc82fe25 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt +++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt @@ -49,6 +49,8 @@ class OrbOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -77,6 +79,46 @@ class OrbOkHttpClient private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`. + */ + fun maxIdleConnections(maxIdleConnections: Optional) = + maxIdleConnections(maxIdleConnections.getOrNull()) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + + /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */ + fun keepAliveDuration(keepAliveDuration: Optional) = + keepAliveDuration(keepAliveDuration.getOrNull()) + /** * The socket factory used to secure HTTPS connections. * @@ -338,6 +380,8 @@ class OrbOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt index 0a71facec..1ae611773 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt +++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt @@ -49,6 +49,8 @@ class OrbOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -77,6 +79,46 @@ class OrbOkHttpClientAsync private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`. + */ + fun maxIdleConnections(maxIdleConnections: Optional) = + maxIdleConnections(maxIdleConnections.getOrNull()) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + + /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */ + fun keepAliveDuration(keepAliveDuration: Optional) = + keepAliveDuration(keepAliveDuration.getOrNull()) + /** * The socket factory used to secure HTTPS connections. * @@ -338,6 +380,8 @@ class OrbOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) diff --git a/orb-java-core/build.gradle.kts b/orb-java-core/build.gradle.kts index 086a58f55..72660d18e 100644 --- a/orb-java-core/build.gradle.kts +++ b/orb-java-core/build.gradle.kts @@ -27,13 +27,11 @@ dependencies { implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") - implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") - implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") testImplementation(kotlin("test")) testImplementation(project(":orb-java-client-okhttp")) testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt index b3cc3efcc..6a41f268b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt @@ -14,6 +14,8 @@ import com.withorb.api.services.blocking.EventService import com.withorb.api.services.blocking.InvoiceLineItemService import com.withorb.api.services.blocking.InvoiceService import com.withorb.api.services.blocking.ItemService +import com.withorb.api.services.blocking.LicenseService +import com.withorb.api.services.blocking.LicenseTypeService import com.withorb.api.services.blocking.MetricService import com.withorb.api.services.blocking.PlanService import com.withorb.api.services.blocking.PriceService @@ -61,40 +63,137 @@ interface OrbClient { fun topLevel(): TopLevelService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun beta(): BetaService + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun coupons(): CouponService + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ fun creditNotes(): CreditNoteService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun customers(): CustomerService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun events(): EventService + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemService + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoices(): InvoiceService + /** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for + * invoices and tax calculation purposes. + */ fun items(): ItemService + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun plans(): PlanService + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceService fun subscriptions(): SubscriptionService fun webhooks(): WebhookService + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertService fun dimensionalPriceGroups(): DimensionalPriceGroupService fun subscriptionChanges(): SubscriptionChangeService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockService + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ + fun licenseTypes(): LicenseTypeService + + fun licenses(): LicenseService + /** * Closes this client, relinquishing any underlying resources. * @@ -120,36 +219,133 @@ interface OrbClient { fun topLevel(): TopLevelService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun beta(): BetaService.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun coupons(): CouponService.WithRawResponse + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ fun creditNotes(): CreditNoteService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun customers(): CustomerService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun events(): EventService.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemService.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoices(): InvoiceService.WithRawResponse + /** + * The Item resource represents a sellable product or good. Items are associated with all + * line items, billable metrics, and prices and are used for defining external sync behavior + * for invoices and tax calculation purposes. + */ fun items(): ItemService.WithRawResponse + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun plans(): PlanService.WithRawResponse + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceService.WithRawResponse fun subscriptions(): SubscriptionService.WithRawResponse + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertService.WithRawResponse fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockService.WithRawResponse + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + fun licenseTypes(): LicenseTypeService.WithRawResponse + + fun licenses(): LicenseService.WithRawResponse } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt index a8b535120..3857f7297 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt @@ -14,6 +14,8 @@ import com.withorb.api.services.async.EventServiceAsync import com.withorb.api.services.async.InvoiceLineItemServiceAsync import com.withorb.api.services.async.InvoiceServiceAsync import com.withorb.api.services.async.ItemServiceAsync +import com.withorb.api.services.async.LicenseServiceAsync +import com.withorb.api.services.async.LicenseTypeServiceAsync import com.withorb.api.services.async.MetricServiceAsync import com.withorb.api.services.async.PlanServiceAsync import com.withorb.api.services.async.PriceServiceAsync @@ -60,38 +62,135 @@ interface OrbClientAsync { fun topLevel(): TopLevelServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun beta(): BetaServiceAsync + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun coupons(): CouponServiceAsync + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ fun creditNotes(): CreditNoteServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun customers(): CustomerServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun events(): EventServiceAsync + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemServiceAsync + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoices(): InvoiceServiceAsync + /** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for + * invoices and tax calculation purposes. + */ fun items(): ItemServiceAsync + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun plans(): PlanServiceAsync + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceServiceAsync fun subscriptions(): SubscriptionServiceAsync + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertServiceAsync fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync fun subscriptionChanges(): SubscriptionChangeServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockServiceAsync + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ + fun licenseTypes(): LicenseTypeServiceAsync + + fun licenses(): LicenseServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -117,36 +216,133 @@ interface OrbClientAsync { fun topLevel(): TopLevelServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun beta(): BetaServiceAsync.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun coupons(): CouponServiceAsync.WithRawResponse + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ fun creditNotes(): CreditNoteServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun customers(): CustomerServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun events(): EventServiceAsync.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemServiceAsync.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoices(): InvoiceServiceAsync.WithRawResponse + /** + * The Item resource represents a sellable product or good. Items are associated with all + * line items, billable metrics, and prices and are used for defining external sync behavior + * for invoices and tax calculation purposes. + */ fun items(): ItemServiceAsync.WithRawResponse + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun plans(): PlanServiceAsync.WithRawResponse + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceServiceAsync.WithRawResponse fun subscriptions(): SubscriptionServiceAsync.WithRawResponse + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertServiceAsync.WithRawResponse fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockServiceAsync.WithRawResponse + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + fun licenseTypes(): LicenseTypeServiceAsync.WithRawResponse + + fun licenses(): LicenseServiceAsync.WithRawResponse } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt index ba4b5c44a..d20aa3a60 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.services.async.InvoiceServiceAsync import com.withorb.api.services.async.InvoiceServiceAsyncImpl import com.withorb.api.services.async.ItemServiceAsync import com.withorb.api.services.async.ItemServiceAsyncImpl +import com.withorb.api.services.async.LicenseServiceAsync +import com.withorb.api.services.async.LicenseServiceAsyncImpl +import com.withorb.api.services.async.LicenseTypeServiceAsync +import com.withorb.api.services.async.LicenseTypeServiceAsyncImpl import com.withorb.api.services.async.MetricServiceAsync import com.withorb.api.services.async.MetricServiceAsyncImpl import com.withorb.api.services.async.PlanServiceAsync @@ -119,6 +123,14 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs CreditBlockServiceAsyncImpl(clientOptionsWithUserAgent) } + private val licenseTypes: LicenseTypeServiceAsync by lazy { + LicenseTypeServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val licenses: LicenseServiceAsync by lazy { + LicenseServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): OrbClient = sync override fun withRawResponse(): OrbClientAsync.WithRawResponse = withRawResponse @@ -128,30 +140,115 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun topLevel(): TopLevelServiceAsync = topLevel + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun beta(): BetaServiceAsync = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun coupons(): CouponServiceAsync = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ override fun creditNotes(): CreditNoteServiceAsync = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun customers(): CustomerServiceAsync = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun events(): EventServiceAsync = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemServiceAsync = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoices(): InvoiceServiceAsync = invoices + /** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for + * invoices and tax calculation purposes. + */ override fun items(): ItemServiceAsync = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricServiceAsync = metrics + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun plans(): PlanServiceAsync = plans + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceServiceAsync = prices override fun subscriptions(): SubscriptionServiceAsync = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertServiceAsync = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync = @@ -159,8 +256,20 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun subscriptionChanges(): SubscriptionChangeServiceAsync = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockServiceAsync = creditBlocks + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ + override fun licenseTypes(): LicenseTypeServiceAsync = licenseTypes + + override fun licenses(): LicenseServiceAsync = licenses + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -235,6 +344,14 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs CreditBlockServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val licenseTypes: LicenseTypeServiceAsync.WithRawResponse by lazy { + LicenseTypeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val licenses: LicenseServiceAsync.WithRawResponse by lazy { + LicenseServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): OrbClientAsync.WithRawResponse = @@ -244,31 +361,116 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun beta(): BetaServiceAsync.WithRawResponse = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun coupons(): CouponServiceAsync.WithRawResponse = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ override fun creditNotes(): CreditNoteServiceAsync.WithRawResponse = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun customers(): CustomerServiceAsync.WithRawResponse = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun events(): EventServiceAsync.WithRawResponse = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemServiceAsync.WithRawResponse = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoices(): InvoiceServiceAsync.WithRawResponse = invoices + /** + * The Item resource represents a sellable product or good. Items are associated with all + * line items, billable metrics, and prices and are used for defining external sync behavior + * for invoices and tax calculation purposes. + */ override fun items(): ItemServiceAsync.WithRawResponse = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricServiceAsync.WithRawResponse = metrics + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun plans(): PlanServiceAsync.WithRawResponse = plans + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceServiceAsync.WithRawResponse = prices override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertServiceAsync.WithRawResponse = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse = @@ -277,6 +479,18 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockServiceAsync.WithRawResponse = creditBlocks + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + override fun licenseTypes(): LicenseTypeServiceAsync.WithRawResponse = licenseTypes + + override fun licenses(): LicenseServiceAsync.WithRawResponse = licenses } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt index 4fa187d47..a39b97ca1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.services.blocking.InvoiceService import com.withorb.api.services.blocking.InvoiceServiceImpl import com.withorb.api.services.blocking.ItemService import com.withorb.api.services.blocking.ItemServiceImpl +import com.withorb.api.services.blocking.LicenseService +import com.withorb.api.services.blocking.LicenseServiceImpl +import com.withorb.api.services.blocking.LicenseTypeService +import com.withorb.api.services.blocking.LicenseTypeServiceImpl import com.withorb.api.services.blocking.MetricService import com.withorb.api.services.blocking.MetricServiceImpl import com.withorb.api.services.blocking.PlanService @@ -111,6 +115,12 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { CreditBlockServiceImpl(clientOptionsWithUserAgent) } + private val licenseTypes: LicenseTypeService by lazy { + LicenseTypeServiceImpl(clientOptionsWithUserAgent) + } + + private val licenses: LicenseService by lazy { LicenseServiceImpl(clientOptionsWithUserAgent) } + override fun async(): OrbClientAsync = async override fun withRawResponse(): OrbClient.WithRawResponse = withRawResponse @@ -120,40 +130,137 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun topLevel(): TopLevelService = topLevel + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun beta(): BetaService = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun coupons(): CouponService = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ override fun creditNotes(): CreditNoteService = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun customers(): CustomerService = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun events(): EventService = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemService = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoices(): InvoiceService = invoices + /** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for + * invoices and tax calculation purposes. + */ override fun items(): ItemService = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricService = metrics + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun plans(): PlanService = plans + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceService = prices override fun subscriptions(): SubscriptionService = subscriptions override fun webhooks(): WebhookService = webhooks + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertService = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupService = dimensionalPriceGroups override fun subscriptionChanges(): SubscriptionChangeService = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockService = creditBlocks + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ + override fun licenseTypes(): LicenseTypeService = licenseTypes + + override fun licenses(): LicenseService = licenses + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -227,6 +334,14 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { CreditBlockServiceImpl.WithRawResponseImpl(clientOptions) } + private val licenseTypes: LicenseTypeService.WithRawResponse by lazy { + LicenseTypeServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val licenses: LicenseService.WithRawResponse by lazy { + LicenseServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): OrbClient.WithRawResponse = @@ -236,30 +351,115 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun topLevel(): TopLevelService.WithRawResponse = topLevel + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun beta(): BetaService.WithRawResponse = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun coupons(): CouponService.WithRawResponse = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ override fun creditNotes(): CreditNoteService.WithRawResponse = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun customers(): CustomerService.WithRawResponse = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun events(): EventService.WithRawResponse = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemService.WithRawResponse = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoices(): InvoiceService.WithRawResponse = invoices + /** + * The Item resource represents a sellable product or good. Items are associated with all + * line items, billable metrics, and prices and are used for defining external sync behavior + * for invoices and tax calculation purposes. + */ override fun items(): ItemService.WithRawResponse = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricService.WithRawResponse = metrics + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun plans(): PlanService.WithRawResponse = plans + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceService.WithRawResponse = prices override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertService.WithRawResponse = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse = @@ -268,6 +468,18 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockService.WithRawResponse = creditBlocks + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + override fun licenseTypes(): LicenseTypeService.WithRawResponse = licenseTypes + + override fun licenses(): LicenseService.WithRawResponse = licenses } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt index cd66b87cb..1de772314 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt @@ -463,6 +463,7 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) apiKey.let { if (!it.isEmpty()) { headers.put("Authorization", "Bearer $it") diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt index 1373ca6ce..575d791e3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt @@ -25,7 +25,7 @@ import java.time.DateTimeException import java.time.LocalDate import java.time.LocalDateTime import java.time.OffsetDateTime -import java.time.ZonedDateTime +import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField @@ -157,14 +157,15 @@ private class LenientOffsetDateTimeDeserializer : val temporal = formatter.parse(p.text) return when { - !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> - LocalDate.from(temporal).atStartOfDay() - !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> - LocalDateTime.from(temporal) - else -> ZonedDateTime.from(temporal).toLocalDateTime() - } - .atZone(context.timeZone.toZoneId()) - .toOffsetDateTime() + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal) + .atStartOfDay() + .atZone(ZoneId.of("UTC")) + .toOffsetDateTime() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal).atZone(ZoneId.of("UTC")).toOffsetDateTime() + else -> OffsetDateTime.from(temporal) + } } catch (e: DateTimeException) { exceptions.add(e) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt index f0f63ba44..e21bb1e93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt @@ -34,8 +34,9 @@ fun getOsName(): String { } } -fun getOsVersion(): String = System.getProperty("os.version", "unknown") +fun getOsVersion(): String = System.getProperty("os.version", "unknown") ?: "unknown" -fun getPackageVersion(): String = OrbClient::class.java.`package`.implementationVersion ?: "unknown" +fun getPackageVersion(): String = + OrbClient::class.java.`package`?.implementationVersion ?: "unknown" -fun getJavaVersion(): String = System.getProperty("java.version", "unknown") +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") ?: "unknown" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt index 3463de9ea..4b7b62d15 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt @@ -8,13 +8,13 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType import com.withorb.api.core.MultipartField +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException +import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream +import java.util.UUID import kotlin.jvm.optionals.getOrNull -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder -import org.apache.hc.core5.http.ContentType -import org.apache.hc.core5.http.HttpEntity @JvmSynthetic internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = @@ -37,69 +37,207 @@ internal fun multipartFormData( jsonMapper: JsonMapper, fields: Map>, ): HttpRequestBody = - object : HttpRequestBody { - private val entity: HttpEntity by lazy { - MultipartEntityBuilder.create() - .apply { - fields.forEach { (name, field) -> - val knownValue = field.value.asKnown().getOrNull() - val parts = - if (knownValue is InputStream) { - // Read directly from the `InputStream` instead of reading it all - // into memory due to the `jsonMapper` serialization below. - sequenceOf(name to knownValue) - } else { - val node = jsonMapper.valueToTree(field.value) - serializePart(name, node) + MultipartBody.Builder() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + val partBody = + if (bytes is ByteArrayInputStream) { + val byteArray = bytes.readBytes() + + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + outputStream.write(byteArray) + } + + override fun contentType(): String = field.contentType + + override fun contentLength(): Long = byteArray.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} } + } else { + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + bytes.copyTo(outputStream) + } + + override fun contentType(): String = field.contentType - parts.forEach { (name, bytes) -> - addBinaryBody( - name, - bytes, - ContentType.parseLenient(field.contentType), - field.filename().getOrNull(), - ) + override fun contentLength(): Long = -1L + + override fun repeatable(): Boolean = false + + override fun close() = bytes.close() + } } - } + + addPart( + MultipartBody.Part.create( + name, + field.filename().getOrNull(), + field.contentType, + partBody, + ) + ) } - .build() + } } + .build() + +private fun serializePart(name: String, node: JsonNode): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().byteInputStream()) + JsonNodeType.BOOLEAN -> sequenceOf(name to node.booleanValue().toString().byteInputStream()) + JsonNodeType.NUMBER -> sequenceOf(name to node.numberValue().toString().byteInputStream()) + JsonNodeType.ARRAY -> + node.elements().asSequence().flatMap { element -> serializePart("$name[]", element) } + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> throw OrbInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") + } - private fun serializePart( - name: String, - node: JsonNode, - ): Sequence> = - when (node.nodeType) { - JsonNodeType.MISSING, - JsonNodeType.NULL -> emptySequence() - JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) - JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) - JsonNodeType.BOOLEAN -> - sequenceOf(name to node.booleanValue().toString().inputStream()) - JsonNodeType.NUMBER -> - sequenceOf(name to node.numberValue().toString().inputStream()) - JsonNodeType.ARRAY -> - node.elements().asSequence().flatMap { element -> - serializePart("$name[]", element) - } - JsonNodeType.OBJECT -> - node.fields().asSequence().flatMap { (key, value) -> - serializePart("$name[$key]", value) - } - JsonNodeType.POJO, - null -> throw OrbInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") +private class MultipartBody +private constructor(private val boundary: String, private val parts: List) : HttpRequestBody { + private val boundaryBytes: ByteArray = boundary.toByteArray() + private val contentType = "multipart/form-data; boundary=$boundary" + + // This must remain in sync with `contentLength`. + override fun writeTo(outputStream: OutputStream) { + parts.forEach { part -> + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(CRLF) + + outputStream.write(CONTENT_DISPOSITION) + outputStream.write(part.contentDisposition.toByteArray()) + outputStream.write(CRLF) + + outputStream.write(CONTENT_TYPE) + outputStream.write(part.contentType.toByteArray()) + outputStream.write(CRLF) + + outputStream.write(CRLF) + part.body.writeTo(outputStream) + outputStream.write(CRLF) + } + + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(DASHDASH) + outputStream.write(CRLF) + } + + override fun contentType(): String = contentType + + // This must remain in sync with `writeTo`. + override fun contentLength(): Long { + var byteCount = 0L + + parts.forEach { part -> + val contentLength = part.body.contentLength() + if (contentLength == -1L) { + return -1L } - private fun String.inputStream(): InputStream = toByteArray().inputStream() + byteCount += + DASHDASH.size + + boundaryBytes.size + + CRLF.size + + CONTENT_DISPOSITION.size + + part.contentDisposition.toByteArray().size + + CRLF.size + + CONTENT_TYPE.size + + part.contentType.toByteArray().size + + CRLF.size + + CRLF.size + + contentLength + + CRLF.size + } - override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + byteCount += DASHDASH.size + boundaryBytes.size + DASHDASH.size + CRLF.size + return byteCount + } - override fun contentType(): String = entity.contentType + override fun repeatable(): Boolean = parts.all { it.body.repeatable() } - override fun contentLength(): Long = entity.contentLength + override fun close() { + parts.forEach { it.body.close() } + } - override fun repeatable(): Boolean = entity.isRepeatable + class Builder { + private val boundary = UUID.randomUUID().toString() + private val parts: MutableList = mutableListOf() - override fun close() = entity.close() + fun addPart(part: Part) = apply { parts.add(part) } + + fun build() = MultipartBody(boundary, parts.toImmutable()) + } + + class Part + private constructor( + val contentDisposition: String, + val contentType: String, + val body: HttpRequestBody, + ) { + companion object { + fun create( + name: String, + filename: String?, + contentType: String, + body: HttpRequestBody, + ): Part { + val disposition = buildString { + append("form-data; name=") + appendQuotedString(name) + if (filename != null) { + append("; filename=") + appendQuotedString(filename) + } + } + return Part(disposition, contentType, body) + } + } + } + + companion object { + private val CRLF = byteArrayOf('\r'.code.toByte(), '\n'.code.toByte()) + private val DASHDASH = byteArrayOf('-'.code.toByte(), '-'.code.toByte()) + private val CONTENT_DISPOSITION = "Content-Disposition: ".toByteArray() + private val CONTENT_TYPE = "Content-Type: ".toByteArray() + + private fun StringBuilder.appendQuotedString(key: String) { + append('"') + for (ch in key) { + when (ch) { + '\n' -> append("%0A") + '\r' -> append("%0D") + '"' -> append("%22") + else -> append(ch) + } + } + append('"') + } } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt index 6bd384bc4..6e0e2fec8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package com.withorb.api.core.http import com.withorb.api.core.DefaultSleeper @@ -212,13 +214,8 @@ private constructor( } } ?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable - // amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter - } + // If the API asks us to wait a certain amount of time, do what it says. + return Duration.ofNanos(retryAfterNanos.toLong()) } // Apply exponential backoff, but not more than the max. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt index f35084b4a..89f9955d4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -41,6 +41,8 @@ private constructor( private val thresholds: JsonField>, private val type: JsonField, private val balanceAlertStatus: JsonField>, + private val groupingKeys: JsonField>, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -67,6 +69,12 @@ private constructor( @JsonProperty("balance_alert_status") @ExcludeMissing balanceAlertStatus: JsonField> = JsonMissing.of(), + @JsonProperty("grouping_keys") + @ExcludeMissing + groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, createdAt, @@ -79,6 +87,8 @@ private constructor( thresholds, type, balanceAlertStatus, + groupingKeys, + licenseType, mutableMapOf(), ) @@ -171,6 +181,23 @@ private constructor( fun balanceAlertStatus(): Optional> = balanceAlertStatus.getOptional("balance_alert_status") + /** + * The property keys to group cost alerts by. Only present for cost alerts with grouping + * enabled. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + + /** + * Minified license type for alert serialization. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -259,6 +286,24 @@ private constructor( @ExcludeMissing fun _balanceAlertStatus(): JsonField> = balanceAlertStatus + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_keys") + @ExcludeMissing + fun _groupingKeys(): JsonField> = groupingKeys + + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -307,6 +352,8 @@ private constructor( private var thresholds: JsonField>? = null private var type: JsonField? = null private var balanceAlertStatus: JsonField>? = null + private var groupingKeys: JsonField>? = null + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -322,6 +369,8 @@ private constructor( thresholds = alert.thresholds.map { it.toMutableList() } type = alert.type balanceAlertStatus = alert.balanceAlertStatus.map { it.toMutableList() } + groupingKeys = alert.groupingKeys.map { it.toMutableList() } + licenseType = alert.licenseType additionalProperties = alert.additionalProperties.toMutableMap() } @@ -510,6 +559,57 @@ private constructor( } } + /** + * The property keys to group cost alerts by. Only present for cost alerts with grouping + * enabled. + */ + fun groupingKeys(groupingKeys: List?) = + groupingKeys(JsonField.ofNullable(groupingKeys)) + + /** Alias for calling [Builder.groupingKeys] with `groupingKeys.orElse(null)`. */ + fun groupingKeys(groupingKeys: Optional>) = + groupingKeys(groupingKeys.getOrNull()) + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + this.groupingKeys = groupingKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { + groupingKeys = + (groupingKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("groupingKeys", it).add(groupingKey) + } + } + + /** Minified license type for alert serialization. */ + fun licenseType(licenseType: LicenseType?) = licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -563,6 +663,8 @@ private constructor( checkRequired("thresholds", thresholds).map { it.toImmutable() }, checkRequired("type", type), (balanceAlertStatus ?: JsonMissing.of()).map { it.toImmutable() }, + (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + licenseType, additionalProperties.toMutableMap(), ) } @@ -585,6 +687,8 @@ private constructor( thresholds().ifPresent { it.forEach { it.validate() } } type().validate() balanceAlertStatus().ifPresent { it.forEach { it.validate() } } + groupingKeys() + licenseType().ifPresent { it.validate() } validated = true } @@ -613,7 +717,9 @@ private constructor( (subscription.asKnown().getOrNull()?.validity() ?: 0) + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + - (balanceAlertStatus.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (balanceAlertStatus.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) /** The metric the alert applies to. */ class Metric @@ -1089,6 +1195,9 @@ private constructor( @JvmField val COST_EXCEEDED = of("cost_exceeded") + @JvmField + val LICENSE_BALANCE_THRESHOLD_REACHED = of("license_balance_threshold_reached") + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -1099,6 +1208,7 @@ private constructor( CREDIT_BALANCE_RECOVERED, USAGE_EXCEEDED, COST_EXCEEDED, + LICENSE_BALANCE_THRESHOLD_REACHED, } /** @@ -1116,6 +1226,7 @@ private constructor( CREDIT_BALANCE_RECOVERED, USAGE_EXCEEDED, COST_EXCEEDED, + LICENSE_BALANCE_THRESHOLD_REACHED, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1134,6 +1245,7 @@ private constructor( CREDIT_BALANCE_RECOVERED -> Value.CREDIT_BALANCE_RECOVERED USAGE_EXCEEDED -> Value.USAGE_EXCEEDED COST_EXCEEDED -> Value.COST_EXCEEDED + LICENSE_BALANCE_THRESHOLD_REACHED -> Value.LICENSE_BALANCE_THRESHOLD_REACHED else -> Value._UNKNOWN } @@ -1152,6 +1264,7 @@ private constructor( CREDIT_BALANCE_RECOVERED -> Known.CREDIT_BALANCE_RECOVERED USAGE_EXCEEDED -> Known.USAGE_EXCEEDED COST_EXCEEDED -> Known.COST_EXCEEDED + LICENSE_BALANCE_THRESHOLD_REACHED -> Known.LICENSE_BALANCE_THRESHOLD_REACHED else -> throw OrbInvalidDataException("Unknown Type: $value") } @@ -1418,6 +1531,159 @@ private constructor( "BalanceAlertStatus{inAlert=$inAlert, thresholdValue=$thresholdValue, additionalProperties=$additionalProperties}" } + /** Minified license type for alert serialization. */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType(checkRequired("id", id), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LicenseType{id=$id, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1435,6 +1701,8 @@ private constructor( thresholds == other.thresholds && type == other.type && balanceAlertStatus == other.balanceAlertStatus && + groupingKeys == other.groupingKeys && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -1451,6 +1719,8 @@ private constructor( thresholds, type, balanceAlertStatus, + groupingKeys, + licenseType, additionalProperties, ) } @@ -1458,5 +1728,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, additionalProperties=$additionalProperties}" + "Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, groupingKeys=$groupingKeys, licenseType=$licenseType, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt index 7329b98c4..295995640 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt @@ -61,6 +61,14 @@ private constructor( */ fun type(): Type = body.type() + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun groupingKeys(): Optional> = body.groupingKeys() + /** * The metric to track usage for. * @@ -69,6 +77,14 @@ private constructor( */ fun metricId(): Optional = body.metricId() + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pricingUnitId(): Optional = body.pricingUnitId() + /** * Returns the raw JSON value of [thresholds]. * @@ -83,6 +99,13 @@ private constructor( */ fun _type(): JsonField = body._type() + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _groupingKeys(): JsonField> = body._groupingKeys() + /** * Returns the raw JSON value of [metricId]. * @@ -90,6 +113,13 @@ private constructor( */ fun _metricId(): JsonField = body._metricId() + /** + * Returns the raw JSON value of [pricingUnitId]. + * + * Unlike [pricingUnitId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _pricingUnitId(): JsonField = body._pricingUnitId() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -146,7 +176,10 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [thresholds] * - [type] + * - [groupingKeys] * - [metricId] + * - [pricingUnitId] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -182,6 +215,31 @@ private constructor( */ fun type(type: JsonField) = apply { body.type(type) } + /** The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. */ + fun groupingKeys(groupingKeys: List?) = apply { body.groupingKeys(groupingKeys) } + + /** Alias for calling [Builder.groupingKeys] with `groupingKeys.orElse(null)`. */ + fun groupingKeys(groupingKeys: Optional>) = + groupingKeys(groupingKeys.getOrNull()) + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + body.groupingKeys(groupingKeys) + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { body.addGroupingKey(groupingKey) } + /** The metric to track usage for. */ fun metricId(metricId: String?) = apply { body.metricId(metricId) } @@ -196,6 +254,24 @@ private constructor( */ fun metricId(metricId: JsonField) = apply { body.metricId(metricId) } + /** The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. */ + fun pricingUnitId(pricingUnitId: String?) = apply { body.pricingUnitId(pricingUnitId) } + + /** Alias for calling [Builder.pricingUnitId] with `pricingUnitId.orElse(null)`. */ + fun pricingUnitId(pricingUnitId: Optional) = + pricingUnitId(pricingUnitId.getOrNull()) + + /** + * Sets [Builder.pricingUnitId] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnitId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pricingUnitId(pricingUnitId: JsonField) = apply { + body.pricingUnitId(pricingUnitId) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -352,7 +428,9 @@ private constructor( private constructor( private val thresholds: JsonField>, private val type: JsonField, + private val groupingKeys: JsonField>, private val metricId: JsonField, + private val pricingUnitId: JsonField, private val additionalProperties: MutableMap, ) { @@ -362,10 +440,16 @@ private constructor( @ExcludeMissing thresholds: JsonField> = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("grouping_keys") + @ExcludeMissing + groupingKeys: JsonField> = JsonMissing.of(), @JsonProperty("metric_id") @ExcludeMissing metricId: JsonField = JsonMissing.of(), - ) : this(thresholds, type, metricId, mutableMapOf()) + @JsonProperty("pricing_unit_id") + @ExcludeMissing + pricingUnitId: JsonField = JsonMissing.of(), + ) : this(thresholds, type, groupingKeys, metricId, pricingUnitId, mutableMapOf()) /** * The thresholds that define the values at which the alert will be triggered. @@ -383,6 +467,14 @@ private constructor( */ fun type(): Type = type.getRequired("type") + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + /** * The metric to track usage for. * @@ -391,6 +483,14 @@ private constructor( */ fun metricId(): Optional = metricId.getOptional("metric_id") + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pricingUnitId(): Optional = pricingUnitId.getOptional("pricing_unit_id") + /** * Returns the raw JSON value of [thresholds]. * @@ -407,6 +507,16 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_keys") + @ExcludeMissing + fun _groupingKeys(): JsonField> = groupingKeys + /** * Returns the raw JSON value of [metricId]. * @@ -414,6 +524,16 @@ private constructor( */ @JsonProperty("metric_id") @ExcludeMissing fun _metricId(): JsonField = metricId + /** + * Returns the raw JSON value of [pricingUnitId]. + * + * Unlike [pricingUnitId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pricing_unit_id") + @ExcludeMissing + fun _pricingUnitId(): JsonField = pricingUnitId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -445,14 +565,18 @@ private constructor( private var thresholds: JsonField>? = null private var type: JsonField? = null + private var groupingKeys: JsonField>? = null private var metricId: JsonField = JsonMissing.of() + private var pricingUnitId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { thresholds = body.thresholds.map { it.toMutableList() } type = body.type + groupingKeys = body.groupingKeys.map { it.toMutableList() } metricId = body.metricId + pricingUnitId = body.pricingUnitId additionalProperties = body.additionalProperties.toMutableMap() } @@ -494,6 +618,39 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + */ + fun groupingKeys(groupingKeys: List?) = + groupingKeys(JsonField.ofNullable(groupingKeys)) + + /** Alias for calling [Builder.groupingKeys] with `groupingKeys.orElse(null)`. */ + fun groupingKeys(groupingKeys: Optional>) = + groupingKeys(groupingKeys.getOrNull()) + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + this.groupingKeys = groupingKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { + groupingKeys = + (groupingKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("groupingKeys", it).add(groupingKey) + } + } + /** The metric to track usage for. */ fun metricId(metricId: String?) = metricId(JsonField.ofNullable(metricId)) @@ -509,6 +666,27 @@ private constructor( */ fun metricId(metricId: JsonField) = apply { this.metricId = metricId } + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + */ + fun pricingUnitId(pricingUnitId: String?) = + pricingUnitId(JsonField.ofNullable(pricingUnitId)) + + /** Alias for calling [Builder.pricingUnitId] with `pricingUnitId.orElse(null)`. */ + fun pricingUnitId(pricingUnitId: Optional) = + pricingUnitId(pricingUnitId.getOrNull()) + + /** + * Sets [Builder.pricingUnitId] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnitId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnitId(pricingUnitId: JsonField) = apply { + this.pricingUnitId = pricingUnitId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -545,7 +723,9 @@ private constructor( Body( checkRequired("thresholds", thresholds).map { it.toImmutable() }, checkRequired("type", type), + (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, metricId, + pricingUnitId, additionalProperties.toMutableMap(), ) } @@ -559,7 +739,9 @@ private constructor( thresholds().forEach { it.validate() } type().validate() + groupingKeys() metricId() + pricingUnitId() validated = true } @@ -581,7 +763,9 @@ private constructor( internal fun validity(): Int = (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (metricId.asKnown().isPresent) 1 else 0) + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (if (metricId.asKnown().isPresent) 1 else 0) + + (if (pricingUnitId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -591,18 +775,27 @@ private constructor( return other is Body && thresholds == other.thresholds && type == other.type && + groupingKeys == other.groupingKeys && metricId == other.metricId && + pricingUnitId == other.pricingUnitId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(thresholds, type, metricId, additionalProperties) + Objects.hash( + thresholds, + type, + groupingKeys, + metricId, + pricingUnitId, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{thresholds=$thresholds, type=$type, metricId=$metricId, additionalProperties=$additionalProperties}" + "Body{thresholds=$thresholds, type=$type, groupingKeys=$groupingKeys, metricId=$metricId, pricingUnitId=$pricingUnitId, additionalProperties=$additionalProperties}" } /** The type of alert to create. This must be a valid alert type. */ diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt index ab6fd5234..88898a4d7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt @@ -27,6 +27,7 @@ private constructor( private val currency: JsonField, private val customExpiration: JsonField, private val filters: JsonField>, + private val licenseTypeId: JsonField, private val additionalProperties: MutableMap, ) { @@ -39,8 +40,13 @@ private constructor( @JsonProperty("custom_expiration") @ExcludeMissing customExpiration: JsonField = JsonMissing.of(), - @JsonProperty("filters") @ExcludeMissing filters: JsonField> = JsonMissing.of(), - ) : this(allowsRollover, currency, customExpiration, filters, mutableMapOf()) + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + ) : this(allowsRollover, currency, customExpiration, filters, licenseTypeId, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -67,6 +73,12 @@ private constructor( */ fun filters(): Optional> = filters.getOptional("filters") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * Returns the raw JSON value of [allowsRollover]. * @@ -100,6 +112,15 @@ private constructor( */ @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -134,6 +155,7 @@ private constructor( private var currency: JsonField? = null private var customExpiration: JsonField? = null private var filters: JsonField>? = null + private var licenseTypeId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -142,6 +164,7 @@ private constructor( currency = allocation.currency customExpiration = allocation.customExpiration filters = allocation.filters.map { it.toMutableList() } + licenseTypeId = allocation.licenseTypeId additionalProperties = allocation.additionalProperties.toMutableMap() } @@ -211,6 +234,24 @@ private constructor( } } + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -250,6 +291,7 @@ private constructor( checkRequired("currency", currency), checkRequired("customExpiration", customExpiration), (filters ?: JsonMissing.of()).map { it.toImmutable() }, + licenseTypeId, additionalProperties.toMutableMap(), ) } @@ -265,6 +307,7 @@ private constructor( currency() customExpiration().ifPresent { it.validate() } filters().ifPresent { it.forEach { it.validate() } } + licenseTypeId() validated = true } @@ -286,7 +329,8 @@ private constructor( (if (allowsRollover.asKnown().isPresent) 1 else 0) + (if (currency.asKnown().isPresent) 1 else 0) + (customExpiration.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -828,15 +872,23 @@ private constructor( currency == other.currency && customExpiration == other.customExpiration && filters == other.filters && + licenseTypeId == other.licenseTypeId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allowsRollover, currency, customExpiration, filters, additionalProperties) + Objects.hash( + allowsRollover, + currency, + customExpiration, + filters, + licenseTypeId, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Allocation{allowsRollover=$allowsRollover, currency=$currency, customExpiration=$customExpiration, filters=$filters, additionalProperties=$additionalProperties}" + "Allocation{allowsRollover=$allowsRollover, currency=$currency, customExpiration=$customExpiration, filters=$filters, licenseTypeId=$licenseTypeId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index c52a84d0c..ec1de92be 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1758,6 +1758,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1768,11 +1769,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1783,6 +1787,15 @@ private constructor( fun allocationPrice(): Optional = allocationPrice.getOptional("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + /** * The phase to add this price to. * @@ -1809,6 +1822,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1848,6 +1871,7 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1855,6 +1879,7 @@ private constructor( @JvmSynthetic internal fun from(addPrice: AddPrice) = apply { allocationPrice = addPrice.allocationPrice + licenseAllocationPrice = addPrice.licenseAllocationPrice planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price additionalProperties = addPrice.additionalProperties.toMutableMap() @@ -1879,6 +1904,331 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -2106,6 +2456,7 @@ private constructor( fun build(): AddPrice = AddPrice( allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap(), @@ -2120,6 +2471,7 @@ private constructor( } allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } planPhaseOrder() price().ifPresent { it.validate() } validated = true @@ -2142,132 +2494,125 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val minimumComposite: MinimumComposite? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { - fun unit(): Optional = Optional.ofNullable(unit) + fun unit(): Optional = Optional.ofNullable(unit) - fun tiered(): Optional = Optional.ofNullable(tiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun bulk(): Optional = Optional.ofNullable(bulk) fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) - fun package_(): Optional = Optional.ofNullable(package_) + fun package_(): Optional = Optional.ofNullable(package_) - fun matrix(): Optional = Optional.ofNullable(matrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun thresholdTotalAmount(): Optional = + fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun tieredWithMinimum(): Optional = + fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) - fun tieredPackageWithMinimum(): Optional = + fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) - fun packageWithAllocation(): Optional = + fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun matrixWithAllocation(): Optional = + fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) - fun unitWithProration(): Optional = + fun unitWithProration(): Optional = Optional.ofNullable(unitWithProration) - fun groupedAllocation(): Optional = + fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) - fun bulkWithProration(): Optional = + fun bulkWithProration(): Optional = Optional.ofNullable(bulkWithProration) - fun groupedWithProratedMinimum(): Optional = + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) - fun groupedWithMeteredMinimum(): Optional = + fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) fun groupedWithMinMaxThresholds(): Optional = Optional.ofNullable(groupedWithMinMaxThresholds) - fun matrixWithDisplayName(): Optional = + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun groupedTieredPackage(): Optional = + fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) - fun maxGroupTieredPackage(): Optional = + fun maxGroupTieredPackage(): Optional = Optional.ofNullable(maxGroupTieredPackage) - fun scalableMatrixWithUnitPricing(): - Optional = + fun scalableMatrixWithUnitPricing(): Optional = Optional.ofNullable(scalableMatrixWithUnitPricing) - fun scalableMatrixWithTieredPricing(): - Optional = + fun scalableMatrixWithTieredPricing(): Optional = Optional.ofNullable(scalableMatrixWithTieredPricing) - fun cumulativeGroupedBulk(): Optional = + fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) - fun minimumComposite(): Optional = + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) fun percent(): Optional = Optional.ofNullable(percent) @@ -2337,85 +2682,82 @@ private constructor( fun isEventOutput(): Boolean = eventOutput != null - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + fun asThresholdTotalAmount(): ThresholdTotalAmount = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + fun asTieredWithMinimum(): TieredWithMinimum = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + fun asPackageWithAllocation(): PackageWithAllocation = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + fun asMatrixWithAllocation(): MatrixWithAllocation = matrixWithAllocation.getOrThrow("matrixWithAllocation") fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + fun asUnitWithProration(): UnitWithProration = unitWithProration.getOrThrow("unitWithProration") - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + fun asGroupedAllocation(): GroupedAllocation = groupedAllocation.getOrThrow("groupedAllocation") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + fun asMatrixWithDisplayName(): MatrixWithDisplayName = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + fun asGroupedTieredPackage(): GroupedTieredPackage = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - fun asMinimumComposite(): NewPlanMinimumCompositePrice = + fun asMinimumComposite(): MinimumComposite = minimumComposite.getOrThrow("minimumComposite") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -2479,22 +2821,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Price = apply { + fun validate(): LicenseAllocationPrice = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { + override fun visitUnit(unit: Unit) { unit.validate() } - override fun visitTiered(tiered: NewPlanTieredPrice) { + override fun visitTiered(tiered: Tiered) { tiered.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { + override fun visitBulk(bulk: Bulk) { bulk.validate() } @@ -2502,54 +2844,50 @@ private constructor( bulkWithFilters.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { + override fun visitPackage(package_: Package) { package_.validate() } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) { thresholdTotalAmount.validate() } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + override fun visitTieredPackage(tieredPackage: TieredPackage) { tieredPackage.validate() } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { tieredWithMinimum.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { groupedTiered.validate() } override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) { tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) { packageWithAllocation.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { unitWithPercent.validate() } override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) { matrixWithAllocation.validate() } @@ -2560,32 +2898,26 @@ private constructor( tieredWithProration.validate() } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { unitWithProration.validate() } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { groupedAllocation.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { bulkWithProration.validate() } override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { groupedWithMeteredMinimum.validate() } @@ -2597,38 +2929,37 @@ private constructor( } override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) { matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) { groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) { maxGroupTieredPackage.validate() } override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { scalableMatrixWithUnitPricing.validate() } override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { scalableMatrixWithTieredPricing.validate() } override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) { cumulativeGroupedBulk.validate() } @@ -2639,9 +2970,7 @@ private constructor( cumulativeGroupedAllocation.validate() } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { minimumComposite.validate() } @@ -2675,72 +3004,66 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = bulkWithFilters.validity() - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) = thresholdTotalAmount.validity() - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + override fun visitTieredPackage(tieredPackage: TieredPackage) = tieredPackage.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) = packageWithAllocation.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) = matrixWithAllocation.validity() override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) = tieredWithProration.validity() - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) = groupedWithMeteredMinimum.validity() override fun visitGroupedWithMinMaxThresholds( @@ -2748,37 +3071,35 @@ private constructor( ) = groupedWithMinMaxThresholds.validity() override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) = matrixWithDisplayName.validity() override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) = groupedTieredPackage.validity() override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = scalableMatrixWithUnitPricing.validity() override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = scalableMatrixWithTieredPricing.validity() override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() override fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() override fun visitPercent(percent: Percent) = percent.validity() @@ -2794,7 +3115,7 @@ private constructor( return true } - return other is Price && + return other is LicenseAllocationPrice && unit == other.unit && tiered == other.tiered && bulk == other.bulk && @@ -2865,522 +3186,521 @@ private constructor( override fun toString(): String = when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } companion object { - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + @JvmStatic fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + @JvmStatic fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) @JvmStatic fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + @JvmStatic + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + @JvmStatic fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) @JvmStatic fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + LicenseAllocationPrice(tieredWithProration = tieredWithProration) @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) @JvmStatic fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic fun ofGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) @JvmStatic fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic fun ofCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) @JvmStatic - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) - @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + @JvmStatic + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) } /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. */ interface Visitor { - fun visitUnit(unit: NewPlanUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitTiered(tiered: NewPlanTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulk(bulk: Bulk): T fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T - fun visitPackage(package_: NewPlanPackagePrice): T + fun visitPackage(package_: Package): T - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ): T - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T fun visitGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun visitMinimumComposite(minimumComposite: MinimumComposite): T fun visitPercent(percent: Percent): T fun visitEventOutput(eventOutput: EventOutput): T /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws OrbInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") } } - internal class Deserializer : BaseDeserializer(Price::class) { + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Price { + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { val json = JsonValue.fromJsonNode(node) val modelType = json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_filters" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_allocation" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "percent" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } } - return Price(_json = json) + return LicenseAllocationPrice(_json = json) } } - internal class Serializer : BaseSerializer(Price::class) { + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { override fun serialize( - value: Price, + value: LicenseAllocationPrice, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -3439,19 +3759,20 @@ private constructor( value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } } } - class BulkWithFilters + class Unit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val unitConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -3464,6 +3785,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -3471,21 +3793,24 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -3522,6 +3847,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3529,11 +3857,12 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3545,45 +3874,48 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), ) /** - * Configuration for bulk_with_filters pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The cadence to bill for this price on. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException 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") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3600,6 +3932,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException 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 unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3704,6 +4045,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -3723,17 +4072,6 @@ private constructor( */ fun referenceId(): Optional = referenceId.getOptional("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -3752,6 +4090,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -3760,6 +4108,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -3873,6 +4231,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3908,27 +4276,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null + private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -3946,49 +4317,36 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -4013,13 +4371,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -4039,6 +4429,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -4387,6 +4791,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -4451,27 +4876,31 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("unitConfig", unitConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4483,6 +4912,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -4491,20 +4921,21 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): Unit = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("unit")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + unitConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -4516,6 +4947,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -4537,11 +4969,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -4553,65 +4987,247 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Property filters to apply (all must match) + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + fun amount(): String = amount.getRequired("amount") /** - * Bulk tiers for rating based on total usage volume + * The currency of the license allocation. * * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + fun currency(): String = currency.getRequired("currency") /** - * Returns the raw JSON value of [filters]. + * When True, overage beyond the allocation is written off. * - * Unlike [filters], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - fun _filters(): JsonField> = filters + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [tiers]. + * Returns the raw JSON value of [currency]. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiers") + @JsonProperty("currency") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4629,85 +5245,89 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .filters() - * .tiers() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var filters: JsonField>? = null - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.filters] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Adds a single [Filter] to [filters]. + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Adds a single [Tier] to [tiers]. + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -4733,35 +5353,37 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFiltersConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .filters() - * .tiers() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): BulkWithFiltersConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - filters().forEach { it.validate() } - tiers().forEach { it.validate() } + amount() + currency() + writeOffOverage() validated = true } @@ -4781,747 +5403,137 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) - - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") - - /** - * Event property value to match - * - * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") - - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey - - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue - - @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 { + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - propertyKey() - propertyValue() - validated = true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } - - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) - - /** - * Amount per unit - * - * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns an immutable instance of [Metadata]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - @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 [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) - - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - 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 [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - unitAmount() - tierLowerBound() - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + validated = true + } - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) + /** + * 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** The cadence to bill for this price on. */ - 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 ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * 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 { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * 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) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - 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 OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - 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 [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode @@ -5533,12 +5545,13 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is Unit && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && + unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -5550,6 +5563,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -5557,11 +5571,12 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5573,6 +5588,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -5582,17 +5598,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class Tiered @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, + private val tieredConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -5605,6 +5622,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -5618,16 +5636,18 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") + @JsonProperty("tiered_config") @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), + tieredConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -5664,6 +5684,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5673,9 +5696,10 @@ private constructor( ) : this( cadence, itemId, + licenseAllocations, modelType, name, - tieredWithProrationConfig, + tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5687,6 +5711,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -5710,12 +5735,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5733,14 +5770,13 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Configuration for tiered_with_proration pricing + * Configuration for tiered pricing * * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") /** * The id of the billable metric for the price. Only needed if the price is @@ -5846,6 +5882,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5883,6 +5927,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -5892,15 +5946,14 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [tieredWithProrationConfig]. + * Returns the raw JSON value of [tieredConfig]. * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiered_with_proration_config") + @JsonProperty("tiered_config") @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig + fun _tieredConfig(): JsonField = tieredConfig /** * Returns the raw JSON value of [billableMetricId]. @@ -6015,6 +6068,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6050,29 +6113,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .itemId() + * .licenseAllocations() * .name() - * .tieredWithProrationConfig() + * .tieredConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = + private var licenseAllocations: JsonField>? = null + private var modelType: JsonValue = JsonValue.from("tiered") + private var name: JsonField? = null + private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -6090,34 +6154,34 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -6144,13 +6208,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6170,21 +6266,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * Sets [Builder.tieredConfig] to an arbitrary JSON value. * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } /** * The id of the billable metric for the price. Only needed if the price is @@ -6534,6 +6629,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6598,7 +6714,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6606,19 +6722,23 @@ private constructor( * ```java * .cadence() * .itemId() + * .licenseAllocations() * .name() - * .tieredWithProrationConfig() + * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + checkRequired("tieredConfig", tieredConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6630,6 +6750,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6638,20 +6759,21 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("tiered")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() + tieredConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -6663,6 +6785,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -6686,11 +6809,11 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -6702,6 +6825,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -6864,40 +6988,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("amount") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + fun amount(): String = amount.getRequired("amount") /** - * Returns the raw JSON value of [tiers]. + * The currency of the license allocation. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 _tiers(): JsonField> = tiers + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -6915,59 +7083,89 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .tiers() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.currency] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.currency] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun currency(currency: JsonField) = apply { + this.currency = currency } + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + /** - * Adds a single [Tier] to [tiers]. + * Alias for [Builder.writeOffOverage]. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * This unboxed primitive overload exists for backwards compatibility. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -6993,32 +7191,37 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + amount() + currency() + writeOffOverage() validated = true } @@ -7038,249 +7241,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException 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 tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @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 [Tier]. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - 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 [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } /** @@ -7399,12 +7383,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is Tiered && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && + tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -7416,6 +7401,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -7425,9 +7411,10 @@ private constructor( Objects.hash( cadence, itemId, + licenseAllocations, modelType, name, - tieredWithProrationConfig, + tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7439,6 +7426,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -7448,16 +7436,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Bulk @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkConfig: JsonField, private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -7472,6 +7460,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -7479,17 +7468,18 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -7532,6 +7522,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7539,9 +7532,10 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkConfig, cadence, - groupedWithMinMaxThresholdsConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -7555,31 +7549,29 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), ) /** - * The cadence to bill for this price on. + * Configuration for bulk pricing * * @throws OrbInvalidDataException 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") + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun cadence(): Cadence = cadence.getRequired("cadence") /** * The id of the item the price will be associated with. @@ -7590,12 +7582,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7716,6 +7720,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7736,25 +7748,24 @@ private constructor( fun referenceId(): Optional = referenceId.getOptional("reference_id") /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [bulkConfig]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cadence") + @JsonProperty("bulk_config") @ExcludeMissing - fun _cadence(): JsonField = cadence + fun _bulkConfig(): JsonField = bulkConfig /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cadence") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _cadence(): JsonField = cadence /** * Returns the raw JSON value of [itemId]. @@ -7764,6 +7775,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -7885,6 +7906,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7920,30 +7951,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java + * .bulkConfig() * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .licenseAllocations() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { + private var bulkConfig: JsonField? = null private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7962,38 +7992,49 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -8007,29 +8048,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -8042,13 +8060,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -8416,6 +8466,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -8480,28 +8551,29 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .bulkConfig() * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .licenseAllocations() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), billableMetricId, @@ -8515,6 +8587,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -8523,16 +8596,17 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } + bulkConfig().validate() cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -8548,6 +8622,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -8569,12 +8644,12 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -8587,6 +8662,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -8749,108 +8825,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + @JsonProperty("amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * The event property used to group before applying thresholds + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + fun amount(): String = amount.getRequired("amount") /** - * The maximum amount to charge each group + * The currency of the license allocation. * * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun currency(): String = currency.getRequired("currency") /** - * The minimum amount to charge each group, regardless of usage + * When True, overage beyond the allocation is written off. * - * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - - /** - * The base price charged per group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [amount]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("amount") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [currency]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [currency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") + @JsonProperty("currency") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [writeOffOverage]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("write_off_overage") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8868,100 +8920,89 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun amount(amount: JsonField) = apply { this.amount = amount } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.currency] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -8987,41 +9028,37 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + amount() + currency() + writeOffOverage() validated = true } @@ -9041,38 +9078,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(amount, currency, writeOffOverage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } /** @@ -9191,11 +9220,11 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Bulk && + bulkConfig == other.bulkConfig && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -9209,6 +9238,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -9216,9 +9246,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + bulkConfig, cadence, - groupedWithMinMaxThresholdsConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -9232,6 +9263,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -9241,16 +9273,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class BulkWithFilters @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -9265,6 +9297,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -9272,17 +9305,18 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -9325,6 +9359,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -9332,9 +9369,10 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkWithFiltersConfig, cadence, - cumulativeGroupedAllocationConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -9348,31 +9386,30 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), ) /** - * The cadence to bill for this price on. + * Configuration for bulk_with_filters pricing * * @throws OrbInvalidDataException 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") + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") /** - * Configuration for cumulative_grouped_allocation pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun cadence(): Cadence = cadence.getRequired("cadence") /** * The id of the item the price will be associated with. @@ -9383,12 +9420,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9509,6 +9558,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9529,25 +9586,25 @@ private constructor( fun referenceId(): Optional = referenceId.getOptional("reference_id") /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [bulkWithFiltersConfig]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("cadence") + @JsonProperty("bulk_with_filters_config") @ExcludeMissing - fun _cadence(): JsonField = cadence + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("cumulative_grouped_allocation_config") + @JsonProperty("cadence") @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig + fun _cadence(): JsonField = cadence /** * Returns the raw JSON value of [itemId]. @@ -9557,6 +9614,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -9678,6 +9745,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9713,30 +9790,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```java + * .bulkWithFiltersConfig() * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .licenseAllocations() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -9755,38 +9831,52 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9800,29 +9890,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9835,13 +9902,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -10209,6 +10308,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10273,28 +10393,29 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .bulkWithFiltersConfig() * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .licenseAllocations() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), billableMetricId, @@ -10308,6 +10429,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -10316,16 +10438,17 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -10341,6 +10464,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -10362,12 +10486,12 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -10380,277 +10504,66 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) - /** The cadence to bill for this price on. */ - 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 ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * 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 { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * 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) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - 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 OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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() - } - - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, - private val groupingKey: JsonField, - private val unitAmount: JsonField, + private val filters: JsonField>, + private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") - @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") - @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("filters") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - mutableMapOf(), - ) - - /** - * The overall allocation across all groups - * - * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") - - /** - * The allocation per individual group - * - * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * The event property used to group usage before applying allocations + * Property filters to apply (all must match) * * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + fun filters(): List = filters.getRequired("filters") /** - * The amount to charge for each unit outside of the allocation + * Bulk tiers for rating based on total usage volume * * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [cumulativeAllocation]. - * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("cumulative_allocation") - @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation - - /** - * Returns the raw JSON value of [groupAllocation]. - * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("group_allocation") - @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [filters]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [filters], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("filters") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _filters(): JsonField> = filters /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [tiers]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("unit_amount") + @JsonProperty("tiers") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _tiers(): JsonField> = tiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -10668,100 +10581,85 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() + * .filters() + * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null - private var groupingKey: JsonField? = null - private var unitAmount: JsonField? = null + private var filters: JsonField>? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + bulkWithFiltersConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) - /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Adds a single [Filter] to [filters]. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } - /** The event property used to group usage before applying allocations */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.tiers] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.tiers] with a well-typed `List` * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - /** The amount to charge for each unit outside of the allocation */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Adds a single [Tier] to [tiers]. * - * You should usually call [Builder.unitAmount] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -10787,41 +10685,35 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() + * .filters() + * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), - checkRequired("groupingKey", groupingKey), - checkRequired("unitAmount", unitAmount), + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() - groupingKey() - unitAmount() + filters().forEach { it.validate() } + tiers().forEach { it.validate() } validated = true } @@ -10841,251 +10733,139656 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && - groupingKey == other.groupingKey && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - additionalProperties, - ) - } + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - override fun hashCode(): Int = hashCode + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Event property value to match + * + * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey - companion object { + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** A builder for [Metadata]. */ - class Builder internal constructor() { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private var additionalProperties: MutableMap = - mutableMapOf() + fun toBuilder() = Builder().from(this) - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + companion object { - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + 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 [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Metadata = apply { - if (validated) { - return@apply + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties } - validated = true + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * 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 = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is CumulativeGroupedAllocation && - cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * 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 - private val hashCode: Int by lazy { - Objects.hash( - cadence, - cumulativeGroupedAllocationConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val ANNUAL = of("annual") - override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - class Percent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val percentConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmField val MONTHLY = of("monthly") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException 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 packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Package]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException 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 matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Matrix]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException 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 thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException 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 consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException 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 totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @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 + * [ConsumptionTable]. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + 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 [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException 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 tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [TieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Optional = + hideZeroAmountTiers.getOptional("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException 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 groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [GroupedTiered]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + private var name: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { + this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException 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 packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [PackageWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException 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 packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @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 + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + 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 [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException 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 unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [UnitWithPercent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException 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 percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException 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 matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException 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 unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [UnitWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException 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 overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @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 + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + 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 [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException 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 bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [BulkWithProration]. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException 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 minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException 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 unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @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 + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + 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 [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException 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 minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException 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 scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException 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 scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException 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 scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @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 + * [ScalingFactor]. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + 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 [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException 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 perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @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 + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException 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 matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException 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 dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException 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 displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException 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 groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException 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 maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException 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 unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException 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 dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException 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 group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @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 + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + 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 [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (group.asKnown().isPresent) 1 else 0) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [DimensionValue]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MinimumComposite + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException 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 minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("minimum_composite") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [minimumCompositeConfig]. + * + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_composite_config") + @ExcludeMissing + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [MinimumComposite]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumComposite]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum_composite") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MinimumComposite]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumComposite = + MinimumComposite( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumComposite = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum_composite")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (minimumCompositeConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Optional = prorated.getOptional("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @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 + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + 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 [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumComposite && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @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 + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + 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 [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @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 + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + 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 [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @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 [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + 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 [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException 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 perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @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 + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @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 + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + 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 [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @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 + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + 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 [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException 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 adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @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 [RemoveAdjustment]. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + 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 [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (adjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException 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 priceId(): String = priceId.getRequired("price_id") + + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @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 [RemovePrice]. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + 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 [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (priceId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException 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 adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException 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 replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @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 [ReplaceAdjustment]. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + 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 [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(maximum) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException 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 replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): Optional = + allocationPrice.getOptional("allocation_price") + + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Optional = price.getOptional("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @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 [ReplacePrice]. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + licenseAllocationPrice = replacePrice.licenseAllocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ + fun price(minimumComposite: NewPlanMinimumCompositePrice) = + price(Price.ofMinimumComposite(minimumComposite)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + 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 [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } + planPhaseOrder() + price().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice + private constructor( + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: MinimumComposite? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): Unit = unit.getOrThrow("unit") + + fun asTiered(): Tiered = tiered.getOrThrow("tiered") + + fun asBulk(): Bulk = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): Package = package_.getOrThrow("package_") + + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): MatrixWithAllocation = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): MinimumComposite = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() + } + + override fun visitTiered(tiered: Tiered) { + tiered.validate() + } + + override fun visitBulk(bulk: Bulk) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: Package) { + package_.validate() + } + + override fun visitMatrix(matrix: Matrix) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitUnit(unit: Unit) = unit.validity() + + override fun visitTiered(tiered: Tiered) = tiered.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: Package) = package_.validity() + + override fun visitMatrix(matrix: Matrix) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocationPrice && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" + thresholdTotalAmount != null -> + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") + } + + companion object { + + @JvmStatic fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) + + @JvmStatic fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) + + @JvmStatic + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + LicenseAllocationPrice(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) + + @JvmStatic + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) + + @JvmStatic + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) + + @JvmStatic + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: Unit): T + + fun visitTiered(tiered: Tiered): T + + fun visitBulk(bulk: Bulk): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: Package): T + + fun visitMatrix(matrix: Matrix): T + + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T + + fun visitTieredPackage(tieredPackage: TieredPackage): T + + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T + + fun visitGroupedTiered(groupedTiered: GroupedTiered): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ): T + + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T + + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T + + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: UnitWithProration): T + + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T + + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T + + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T + + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ): T + + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: MinimumComposite): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. + * + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") + } + } + + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "minimum_composite" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + } + + return LicenseAllocationPrice(_json = json) + } + } + + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { + + override fun serialize( + value: LicenseAllocationPrice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") + } + } + } + + class Unit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException 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 unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Unit]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Unit]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Unit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Unit = + Unit( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Tiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered pricing + * + * @throws OrbInvalidDataException 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 tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredConfig]. + * + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Tiered]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered") + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) + + /** + * Sets [Builder.tieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Tiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tiered = + Tiered( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tiered && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Bulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk pricing + * + * @throws OrbInvalidDataException 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 bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkConfig]. + * + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Bulk]. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Bulk]. */ + class Builder internal constructor() { + + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Bulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Bulk = apply { + if (validated) { + return@apply + } + + bulkConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Bulk && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @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 [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + 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 [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException 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 packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Package]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException 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 matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Matrix]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException 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 thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException 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 consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException 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 totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @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 + * [ConsumptionTable]. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + 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 [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException 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 tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [TieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Optional = + hideZeroAmountTiers.getOptional("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException 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 groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [GroupedTiered]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + private var name: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { + this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException 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 packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [PackageWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException 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 packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @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 + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + 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 [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException 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 unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [UnitWithPercent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException 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 percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException 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 matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException 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 unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [UnitWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException 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 overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @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 + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + 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 [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException 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 bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [BulkWithProration]. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException 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 minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException 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 unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @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 + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + 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 [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException 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 minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException 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 scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException 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 scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException 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 scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @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 + * [ScalingFactor]. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + 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 [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException 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 perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @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 + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException 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 matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException 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 dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException 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 displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException 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 groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException 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 maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException 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 unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException 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 dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException 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 group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @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 + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + 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 [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (group.asKnown().isPresent) 1 else 0) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [DimensionValue]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MinimumComposite + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -11122,6 +150419,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -11131,9 +150431,10 @@ private constructor( ) : this( cadence, itemId, + licenseAllocations, + minimumCompositeConfig, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11145,6 +150446,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -11168,12 +150470,34 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException 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 minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("percent") + * JsonValue.from("minimum_composite") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11190,15 +150514,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11303,6 +150618,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -11341,22 +150664,33 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [licenseAllocations]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations /** - * Returns the raw JSON value of [percentConfig]. + * Returns the raw JSON value of [minimumCompositeConfig]. * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("percent_config") + @JsonProperty("minimum_composite_config") @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [billableMetricId]. @@ -11471,6 +150805,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11506,27 +150850,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of [MinimumComposite]. * * The following fields are required: * ```java * .cadence() * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() * .name() - * .percentConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [MinimumComposite]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -11544,31 +150891,36 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -11595,13 +150947,60 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("percent") + * JsonValue.from("minimum_composite") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11621,21 +151020,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11984,6 +151368,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12048,7 +151453,7 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [MinimumComposite]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12056,19 +151461,23 @@ private constructor( * ```java * .cadence() * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): MinimumComposite = + MinimumComposite( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12080,6 +151489,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -12088,20 +151498,21 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + fun validate(): MinimumComposite = apply { if (validated) { return@apply } cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("minimum_composite")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -12113,6 +151524,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -12136,9 +151548,11 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (minimumCompositeConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -12150,6 +151564,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -12312,39 +151727,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("amount") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * What percent of the component subtotals to charge + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + fun amount(): String = amount.getRequired("amount") /** - * Returns the raw JSON value of [percent]. + * The currency of the license allocation. * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("amount") @ExcludeMissing - fun _percent(): JsonField = percent + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -12362,40 +151822,90 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .percent() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } fun additionalProperties(additionalProperties: Map) = apply { @@ -12420,32 +151930,37 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .percent() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - percent() + amount() + currency() + writeOffOverage() validated = true } @@ -12464,26 +151979,255 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash(amount, currency, writeOffOverage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Optional = prorated.getOptional("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @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 + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + 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 [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } /** @@ -12602,12 +152346,13 @@ private constructor( return true } - return other is Percent && + return other is MinimumComposite && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12619,6 +152364,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12628,9 +152374,10 @@ private constructor( Objects.hash( cadence, itemId, + licenseAllocations, + minimumCompositeConfig, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12642,6 +152389,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12651,17 +152399,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12674,6 +152423,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12684,18 +152434,21 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12732,6 +152485,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12740,10 +152496,11 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, + licenseAllocations, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12755,6 +152512,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12770,30 +152528,32 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for event_output pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12810,6 +152570,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12914,6 +152683,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12943,16 +152720,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -12961,6 +152728,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -12969,6 +152746,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -13082,6 +152869,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -13117,27 +152914,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() * .itemId() + * .licenseAllocations() * .name() + * .percentConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -13155,31 +152955,34 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -13194,21 +152997,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -13221,13 +153009,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13247,6 +153067,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13595,6 +153430,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13659,27 +153515,31 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() * .itemId() + * .licenseAllocations() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13691,6 +153551,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13699,20 +153560,21 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -13724,6 +153586,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13746,10 +153609,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -13761,6 +153626,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13923,87 +153789,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") + @JsonProperty("amount") @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + fun amount(): String = amount.getRequired("amount") /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. + * The currency of the license allocation. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException 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 defaultUnitRate(): Optional = - defaultUnitRate.getOptional("default_unit_rate") + fun currency(): String = currency.getRequired("currency") /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. + * When True, overage beyond the allocation is written off. * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") /** - * Returns the raw JSON value of [unitRatingKey]. + * Returns the raw JSON value of [amount]. * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_rating_key") + @JsonProperty("amount") @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [defaultUnitRate]. + * Returns the raw JSON value of [currency]. * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * Unlike [currency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("default_unit_rate") + @JsonProperty("currency") @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [writeOffOverage]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("write_off_overage") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -14021,98 +153884,274 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .unitRatingKey() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency } + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Alias for calling [Builder.defaultUnitRate] with - * `defaultUnitRate.orElse(null)`. + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. */ - fun defaultUnitRate(defaultUnitRate: Optional) = - defaultUnitRate(defaultUnitRate.getOrNull()) + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * You should usually call [Builder.defaultUnitRate] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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) } /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @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 { /** - * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` */ - fun groupingKey(groupingKey: Optional) = - groupingKey(groupingKey.getOrNull()) + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -14137,36 +154176,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() - groupingKey() + percent() validated = true } @@ -14185,36 +154220,26 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (if (unitRatingKey.asKnown().isPresent) 1 else 0) + - (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -14333,12 +154358,13 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -14350,6 +154376,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -14358,10 +154385,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, + licenseAllocations, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14373,1556 +154401,2154 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, ) } - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") - override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - override fun hashCode(): Int = hashCode + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException 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 adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun toBuilder() = Builder().from(this) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - companion object { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * 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 - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - private var validated: Boolean = false + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - /** - * 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 (adjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun hashCode(): Int = hashCode + fun toBuilder() = Builder().from(this) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + companion object { - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException 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 priceId(): String = priceId.getRequired("price_id") + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * 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 } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - fun toBuilder() = Builder().from(this) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - companion object { + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - priceId() - planPhaseOrder() - validated = true - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * 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 (priceId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException 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 adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException 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 replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun toBuilder() = Builder().from(this) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - companion object { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + private var validated: Boolean = false - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - private var validated: Boolean = 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + /** + * 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 - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { - /** - * 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 = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + @JvmField val ANNUAL = of("annual") - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + @JvmField val MONTHLY = of("monthly") - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + @JvmField val QUARTERLY = of("quarterly") - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + @JvmField val ONE_TIME = of("one_time") - fun minimum(): Optional = Optional.ofNullable(minimum) + @JvmField val CUSTOM = of("custom") - fun maximum(): Optional = Optional.ofNullable(maximum) + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun isMinimum(): Boolean = minimum != null + /** + * 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun isMaximum(): Boolean = maximum != null + /** + * 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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + private var validated: Boolean = false - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + known() + validated = true + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * 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 - fun _json(): Optional = Optional.ofNullable(_json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + return other is Cadence && value == other.value + } - private var validated: Boolean = false + override fun hashCode() = value.hashCode() - fun validate(): Adjustment = apply { - if (validated) { - return@apply + override fun toString() = value.toString() } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - /** - * 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 = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun toBuilder() = Builder().from(this) - override fun unknown(json: JsonValue?) = 0 + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - companion object { + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitMinimum(minimum: NewMinimum): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMaximum(maximum: NewMaximum): T + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + private var validated: Boolean = false - internal class Deserializer : BaseDeserializer(Adjustment::class) { + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - } - return Adjustment(_json = json) - } - } + /** + * 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 (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException 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 replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): Optional = - allocationPrice.getOptional("allocation_price") + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") - /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + /** + * 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 [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + companion object { - fun toBuilder() = Builder().from(this) + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - companion object { + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + amount() + currency() + writeOffOverage() + validated = true + } - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + /** + * 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + companion object { - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + private var additionalProperties: MutableMap = + mutableMapOf() - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + private var validated: Boolean = false - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + validated = true + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. - */ - fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = - price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ - fun price(minimumComposite: NewPlanMinimumCompositePrice) = - price(Price.ofMinimumComposite(minimumComposite)) + /** + * 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode(): Int = hashCode - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - private var validated: Boolean = false + override fun hashCode(): Int = hashCode - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - planPhaseOrder() - price().ifPresent { it.validate() } - validated = true } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) - /** New plan price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -17242,6 +157868,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -17300,6 +157927,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -17323,6 +157953,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -17482,6 +158113,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -17651,6 +158290,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -17724,6 +158373,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -17747,6 +158397,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -18165,6 +158816,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -18261,6 +158933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -18294,6 +158967,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -18331,6 +159005,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -19328,6 +160003,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -19351,6 +160027,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -19360,7 +160037,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -19383,6 +160060,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -19442,6 +160120,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -19465,6 +160146,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -19624,6 +160306,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -19793,6 +160483,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -19868,6 +160568,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -19892,6 +160593,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -20312,6 +161014,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -20408,6 +161131,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -20441,6 +161165,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -20480,6 +161205,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -21194,6 +161920,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -21217,6 +161944,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -21226,7 +161954,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -21250,6 +161978,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -21310,6 +162039,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -21333,6 +162065,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -21494,6 +162227,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -21663,6 +162404,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -21740,6 +162491,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -21767,6 +162519,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -22194,6 +162947,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -22293,6 +163067,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -22326,6 +163101,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -22365,6 +163141,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -22987,6 +163764,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -23010,6 +163788,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -23019,7 +163798,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -23043,6 +163822,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23103,6 +163883,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23126,6 +163909,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23287,6 +164071,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -23456,6 +164248,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -23533,6 +164335,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -23560,6 +164363,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -23987,6 +164791,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -24086,6 +164911,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24119,6 +164945,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -24158,6 +164985,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -24787,6 +165615,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24810,6 +165639,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24819,7 +165649,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -24842,6 +165672,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24900,6 +165731,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24923,6 +165757,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -25081,6 +165916,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -25249,6 +166092,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25322,6 +166175,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25344,6 +166198,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -25762,6 +166617,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25858,6 +166734,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25891,6 +166768,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -25928,6 +166806,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -26397,6 +167276,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26420,6 +167300,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26429,7 +167310,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -26452,6 +167333,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26510,6 +167392,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26533,6 +167418,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26692,6 +167578,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -26860,6 +167754,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -26933,6 +167837,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -26955,6 +167860,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -27373,6 +168279,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27469,6 +168396,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27502,6 +168430,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -27539,6 +168468,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -28128,6 +169058,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -28151,6 +169082,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -28160,7 +169092,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -28172,6 +169104,7 @@ private constructor( return other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties @@ -28181,6 +169114,7 @@ private constructor( Objects.hash( replacesPriceId, allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties, @@ -28190,7 +169124,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 7f3b7ebb3..8f9aa0ad3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1764,6 +1764,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1774,11 +1775,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1789,6 +1793,15 @@ private constructor( fun allocationPrice(): Optional = allocationPrice.getOptional("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + /** * The phase to add this price to. * @@ -1815,6 +1828,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1854,6 +1877,7 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1861,6 +1885,7 @@ private constructor( @JvmSynthetic internal fun from(addPrice: AddPrice) = apply { allocationPrice = addPrice.allocationPrice + licenseAllocationPrice = addPrice.licenseAllocationPrice planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price additionalProperties = addPrice.additionalProperties.toMutableMap() @@ -1885,6 +1910,331 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -2112,6 +2462,7 @@ private constructor( fun build(): AddPrice = AddPrice( allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap(), @@ -2126,6 +2477,7 @@ private constructor( } allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } planPhaseOrder() price().ifPresent { it.validate() } validated = true @@ -2148,132 +2500,125 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val minimumComposite: MinimumComposite? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { - fun unit(): Optional = Optional.ofNullable(unit) + fun unit(): Optional = Optional.ofNullable(unit) - fun tiered(): Optional = Optional.ofNullable(tiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun bulk(): Optional = Optional.ofNullable(bulk) fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) - fun package_(): Optional = Optional.ofNullable(package_) + fun package_(): Optional = Optional.ofNullable(package_) - fun matrix(): Optional = Optional.ofNullable(matrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun thresholdTotalAmount(): Optional = + fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun tieredWithMinimum(): Optional = + fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) - fun tieredPackageWithMinimum(): Optional = + fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) - fun packageWithAllocation(): Optional = + fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun matrixWithAllocation(): Optional = + fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) - fun unitWithProration(): Optional = + fun unitWithProration(): Optional = Optional.ofNullable(unitWithProration) - fun groupedAllocation(): Optional = + fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) - fun bulkWithProration(): Optional = + fun bulkWithProration(): Optional = Optional.ofNullable(bulkWithProration) - fun groupedWithProratedMinimum(): Optional = + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) - fun groupedWithMeteredMinimum(): Optional = + fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) fun groupedWithMinMaxThresholds(): Optional = Optional.ofNullable(groupedWithMinMaxThresholds) - fun matrixWithDisplayName(): Optional = + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun groupedTieredPackage(): Optional = + fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) - fun maxGroupTieredPackage(): Optional = + fun maxGroupTieredPackage(): Optional = Optional.ofNullable(maxGroupTieredPackage) - fun scalableMatrixWithUnitPricing(): - Optional = + fun scalableMatrixWithUnitPricing(): Optional = Optional.ofNullable(scalableMatrixWithUnitPricing) - fun scalableMatrixWithTieredPricing(): - Optional = + fun scalableMatrixWithTieredPricing(): Optional = Optional.ofNullable(scalableMatrixWithTieredPricing) - fun cumulativeGroupedBulk(): Optional = + fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) - fun minimumComposite(): Optional = + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) fun percent(): Optional = Optional.ofNullable(percent) @@ -2343,85 +2688,82 @@ private constructor( fun isEventOutput(): Boolean = eventOutput != null - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + fun asThresholdTotalAmount(): ThresholdTotalAmount = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + fun asTieredWithMinimum(): TieredWithMinimum = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + fun asPackageWithAllocation(): PackageWithAllocation = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + fun asMatrixWithAllocation(): MatrixWithAllocation = matrixWithAllocation.getOrThrow("matrixWithAllocation") fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + fun asUnitWithProration(): UnitWithProration = unitWithProration.getOrThrow("unitWithProration") - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + fun asGroupedAllocation(): GroupedAllocation = groupedAllocation.getOrThrow("groupedAllocation") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + fun asMatrixWithDisplayName(): MatrixWithDisplayName = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + fun asGroupedTieredPackage(): GroupedTieredPackage = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - fun asMinimumComposite(): NewPlanMinimumCompositePrice = + fun asMinimumComposite(): MinimumComposite = minimumComposite.getOrThrow("minimumComposite") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -2485,22 +2827,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Price = apply { + fun validate(): LicenseAllocationPrice = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { + override fun visitUnit(unit: Unit) { unit.validate() } - override fun visitTiered(tiered: NewPlanTieredPrice) { + override fun visitTiered(tiered: Tiered) { tiered.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { + override fun visitBulk(bulk: Bulk) { bulk.validate() } @@ -2508,54 +2850,50 @@ private constructor( bulkWithFilters.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { + override fun visitPackage(package_: Package) { package_.validate() } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) { thresholdTotalAmount.validate() } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + override fun visitTieredPackage(tieredPackage: TieredPackage) { tieredPackage.validate() } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { tieredWithMinimum.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { groupedTiered.validate() } override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) { tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) { packageWithAllocation.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { unitWithPercent.validate() } override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) { matrixWithAllocation.validate() } @@ -2566,32 +2904,26 @@ private constructor( tieredWithProration.validate() } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { unitWithProration.validate() } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { groupedAllocation.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { bulkWithProration.validate() } override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { groupedWithMeteredMinimum.validate() } @@ -2603,38 +2935,37 @@ private constructor( } override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) { matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) { groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) { maxGroupTieredPackage.validate() } override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { scalableMatrixWithUnitPricing.validate() } override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { scalableMatrixWithTieredPricing.validate() } override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) { cumulativeGroupedBulk.validate() } @@ -2645,9 +2976,7 @@ private constructor( cumulativeGroupedAllocation.validate() } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { minimumComposite.validate() } @@ -2681,72 +3010,66 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = bulkWithFilters.validity() - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) = thresholdTotalAmount.validity() - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + override fun visitTieredPackage(tieredPackage: TieredPackage) = tieredPackage.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) = packageWithAllocation.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) = matrixWithAllocation.validity() override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) = tieredWithProration.validity() - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) = groupedWithMeteredMinimum.validity() override fun visitGroupedWithMinMaxThresholds( @@ -2754,37 +3077,35 @@ private constructor( ) = groupedWithMinMaxThresholds.validity() override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) = matrixWithDisplayName.validity() override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) = groupedTieredPackage.validity() override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = scalableMatrixWithUnitPricing.validity() override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = scalableMatrixWithTieredPricing.validity() override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() override fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() override fun visitPercent(percent: Percent) = percent.validity() @@ -2800,7 +3121,7 @@ private constructor( return true } - return other is Price && + return other is LicenseAllocationPrice && unit == other.unit && tiered == other.tiered && bulk == other.bulk && @@ -2871,522 +3192,521 @@ private constructor( override fun toString(): String = when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } companion object { - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + @JvmStatic fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + @JvmStatic fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) @JvmStatic fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + @JvmStatic + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + @JvmStatic fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) @JvmStatic fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + LicenseAllocationPrice(tieredWithProration = tieredWithProration) @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) @JvmStatic fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic fun ofGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) @JvmStatic fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic fun ofCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) @JvmStatic - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) - @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + @JvmStatic + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) } /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. */ interface Visitor { - fun visitUnit(unit: NewPlanUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitTiered(tiered: NewPlanTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulk(bulk: Bulk): T fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T - fun visitPackage(package_: NewPlanPackagePrice): T + fun visitPackage(package_: Package): T - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ): T - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T fun visitGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun visitMinimumComposite(minimumComposite: MinimumComposite): T fun visitPercent(percent: Percent): T fun visitEventOutput(eventOutput: EventOutput): T /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws OrbInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") } } - internal class Deserializer : BaseDeserializer(Price::class) { + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Price { + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { val json = JsonValue.fromJsonNode(node) val modelType = json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_filters" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_allocation" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "percent" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } } - return Price(_json = json) + return LicenseAllocationPrice(_json = json) } } - internal class Serializer : BaseSerializer(Price::class) { + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { override fun serialize( - value: Price, + value: LicenseAllocationPrice, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -3445,19 +3765,20 @@ private constructor( value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } } } - class BulkWithFilters + class Unit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val unitConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -3470,6 +3791,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -3477,21 +3799,24 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -3528,6 +3853,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3535,11 +3863,12 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3551,45 +3880,48 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), ) /** - * Configuration for bulk_with_filters pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The cadence to bill for this price on. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException 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") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3606,6 +3938,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException 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 unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3710,6 +4051,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -3729,17 +4078,6 @@ private constructor( */ fun referenceId(): Optional = referenceId.getOptional("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -3758,6 +4096,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -3766,6 +4114,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -3879,6 +4237,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3914,27 +4282,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null + private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -3952,49 +4323,36 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -4019,13 +4377,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -4045,6 +4435,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -4393,6 +4797,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -4457,27 +4882,31 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("unitConfig", unitConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -4489,6 +4918,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -4497,20 +4927,21 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): Unit = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("unit")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + unitConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -4522,6 +4953,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -4543,11 +4975,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -4559,65 +4993,247 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Property filters to apply (all must match) + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + fun amount(): String = amount.getRequired("amount") /** - * Bulk tiers for rating based on total usage volume + * The currency of the license allocation. * * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + fun currency(): String = currency.getRequired("currency") /** - * Returns the raw JSON value of [filters]. + * When True, overage beyond the allocation is written off. * - * Unlike [filters], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - fun _filters(): JsonField> = filters + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [tiers]. + * Returns the raw JSON value of [currency]. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiers") + @JsonProperty("currency") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4635,85 +5251,89 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .filters() - * .tiers() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var filters: JsonField>? = null - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.filters] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Adds a single [Filter] to [filters]. + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Adds a single [Tier] to [tiers]. + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -4739,35 +5359,37 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFiltersConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .filters() - * .tiers() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): BulkWithFiltersConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - filters().forEach { it.validate() } - tiers().forEach { it.validate() } + amount() + currency() + writeOffOverage() validated = true } @@ -4787,747 +5409,137 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) - - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") - - /** - * Event property value to match - * - * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") - - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey - - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue - - @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 { + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - propertyKey() - propertyValue() - validated = true + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } - - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) - - /** - * Amount per unit - * - * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns an immutable instance of [Metadata]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - @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 [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) - - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - 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 [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - unitAmount() - tierLowerBound() - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + validated = true + } - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) + /** + * 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** The cadence to bill for this price on. */ - 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 ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * 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 { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * 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) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - 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 OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - 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 [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode @@ -5539,12 +5551,13 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is Unit && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && + unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -5556,6 +5569,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -5563,11 +5577,12 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5579,6 +5594,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -5588,17 +5604,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class Tiered @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, + private val tieredConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -5611,6 +5628,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -5624,16 +5642,18 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") + @JsonProperty("tiered_config") @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), + tieredConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -5670,6 +5690,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5679,9 +5702,10 @@ private constructor( ) : this( cadence, itemId, + licenseAllocations, modelType, name, - tieredWithProrationConfig, + tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5693,6 +5717,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -5716,12 +5741,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("tiered") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5739,14 +5776,13 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Configuration for tiered_with_proration pricing + * Configuration for tiered pricing * * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") /** * The id of the billable metric for the price. Only needed if the price is @@ -5852,6 +5888,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5889,6 +5933,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -5898,15 +5952,14 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [tieredWithProrationConfig]. + * Returns the raw JSON value of [tieredConfig]. * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiered_with_proration_config") + @JsonProperty("tiered_config") @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig + fun _tieredConfig(): JsonField = tieredConfig /** * Returns the raw JSON value of [billableMetricId]. @@ -6021,6 +6074,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6056,29 +6119,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .itemId() + * .licenseAllocations() * .name() - * .tieredWithProrationConfig() + * .tieredConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = + private var licenseAllocations: JsonField>? = null + private var modelType: JsonValue = JsonValue.from("tiered") + private var name: JsonField? = null + private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -6096,34 +6160,34 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -6150,13 +6214,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("tiered") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6176,21 +6272,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * Sets [Builder.tieredConfig] to an arbitrary JSON value. * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } /** * The id of the billable metric for the price. Only needed if the price is @@ -6540,6 +6635,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6604,7 +6720,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6612,19 +6728,23 @@ private constructor( * ```java * .cadence() * .itemId() + * .licenseAllocations() * .name() - * .tieredWithProrationConfig() + * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + checkRequired("tieredConfig", tieredConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6636,6 +6756,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6644,20 +6765,21 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("tiered")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() + tieredConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -6669,6 +6791,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -6692,11 +6815,11 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -6708,6 +6831,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -6870,40 +6994,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("amount") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + fun amount(): String = amount.getRequired("amount") /** - * Returns the raw JSON value of [tiers]. + * The currency of the license allocation. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 _tiers(): JsonField> = tiers + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -6921,59 +7089,89 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .tiers() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.currency] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.currency] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun currency(currency: JsonField) = apply { + this.currency = currency } + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + /** - * Adds a single [Tier] to [tiers]. + * Alias for [Builder.writeOffOverage]. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * This unboxed primitive overload exists for backwards compatibility. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -6999,32 +7197,37 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + amount() + currency() + writeOffOverage() validated = true } @@ -7044,249 +7247,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException 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 tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @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 [Tier]. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - 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 [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } /** @@ -7405,12 +7389,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is Tiered && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && + tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -7422,6 +7407,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -7431,9 +7417,10 @@ private constructor( Objects.hash( cadence, itemId, + licenseAllocations, modelType, name, - tieredWithProrationConfig, + tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7445,6 +7432,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -7454,16 +7442,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class Bulk @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkConfig: JsonField, private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -7478,6 +7466,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -7485,17 +7474,18 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -7538,6 +7528,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7545,9 +7538,10 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkConfig, cadence, - groupedWithMinMaxThresholdsConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -7561,31 +7555,29 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), ) /** - * The cadence to bill for this price on. + * Configuration for bulk pricing * * @throws OrbInvalidDataException 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") + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun cadence(): Cadence = cadence.getRequired("cadence") /** * The id of the item the price will be associated with. @@ -7596,12 +7588,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7722,6 +7726,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7742,25 +7754,24 @@ private constructor( fun referenceId(): Optional = referenceId.getOptional("reference_id") /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [bulkConfig]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cadence") + @JsonProperty("bulk_config") @ExcludeMissing - fun _cadence(): JsonField = cadence + fun _bulkConfig(): JsonField = bulkConfig /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("cadence") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _cadence(): JsonField = cadence /** * Returns the raw JSON value of [itemId]. @@ -7770,6 +7781,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -7891,6 +7912,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7926,30 +7957,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java + * .bulkConfig() * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .licenseAllocations() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { + private var bulkConfig: JsonField? = null private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7968,38 +7998,49 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -8013,29 +8054,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -8048,13 +8066,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("bulk") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -8422,6 +8472,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -8486,28 +8557,29 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .bulkConfig() * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .licenseAllocations() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), billableMetricId, @@ -8521,6 +8593,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -8529,16 +8602,17 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } + bulkConfig().validate() cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("bulk")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -8554,6 +8628,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -8575,12 +8650,12 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -8593,6 +8668,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -8755,108 +8831,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + @JsonProperty("amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * The event property used to group before applying thresholds + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + fun amount(): String = amount.getRequired("amount") /** - * The maximum amount to charge each group + * The currency of the license allocation. * * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun currency(): String = currency.getRequired("currency") /** - * The minimum amount to charge each group, regardless of usage + * When True, overage beyond the allocation is written off. * - * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - - /** - * The base price charged per group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [amount]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("amount") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [currency]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [currency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") + @JsonProperty("currency") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [writeOffOverage]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("write_off_overage") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8874,100 +8926,89 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun amount(amount: JsonField) = apply { this.amount = amount } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.currency] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage } fun additionalProperties(additionalProperties: Map) = @@ -8993,41 +9034,37 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + amount() + currency() + writeOffOverage() validated = true } @@ -9047,38 +9084,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(amount, currency, writeOffOverage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } /** @@ -9197,11 +9226,11 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is Bulk && + bulkConfig == other.bulkConfig && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -9215,6 +9244,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -9222,9 +9252,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + bulkConfig, cadence, - groupedWithMinMaxThresholdsConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -9238,6 +9269,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -9247,16 +9279,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class BulkWithFilters @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -9271,6 +9303,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -9278,17 +9311,18 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -9331,6 +9365,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -9338,9 +9375,10 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( + bulkWithFiltersConfig, cadence, - cumulativeGroupedAllocationConfig, itemId, + licenseAllocations, modelType, name, billableMetricId, @@ -9354,31 +9392,30 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), ) /** - * The cadence to bill for this price on. + * Configuration for bulk_with_filters pricing * * @throws OrbInvalidDataException 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") + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") /** - * Configuration for cumulative_grouped_allocation pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun cadence(): Cadence = cadence.getRequired("cadence") /** * The id of the item the price will be associated with. @@ -9389,12 +9426,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -9515,6 +9564,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9535,25 +9592,25 @@ private constructor( fun referenceId(): Optional = referenceId.getOptional("reference_id") /** - * Returns the raw JSON value of [cadence]. + * Returns the raw JSON value of [bulkWithFiltersConfig]. * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("cadence") + @JsonProperty("bulk_with_filters_config") @ExcludeMissing - fun _cadence(): JsonField = cadence + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * Returns the raw JSON value of [cadence]. * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("cumulative_grouped_allocation_config") + @JsonProperty("cadence") @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig + fun _cadence(): JsonField = cadence /** * Returns the raw JSON value of [itemId]. @@ -9563,6 +9620,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -9684,6 +9751,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9719,30 +9796,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```java + * .bulkWithFiltersConfig() * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .licenseAllocations() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -9761,38 +9837,52 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9806,29 +9896,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9841,13 +9908,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -10215,6 +10314,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10279,28 +10399,29 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .bulkWithFiltersConfig() * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .licenseAllocations() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), billableMetricId, @@ -10314,6 +10435,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -10322,16 +10444,17 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -10347,6 +10470,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -10368,12 +10492,12 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -10386,277 +10510,66 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) - /** The cadence to bill for this price on. */ - 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 ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * 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 { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * 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) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - 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 OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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() - } - - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, - private val groupingKey: JsonField, - private val unitAmount: JsonField, + private val filters: JsonField>, + private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") - @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") - @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + @JsonProperty("filters") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - mutableMapOf(), - ) - - /** - * The overall allocation across all groups - * - * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") - - /** - * The allocation per individual group - * - * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * The event property used to group usage before applying allocations + * Property filters to apply (all must match) * * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + fun filters(): List = filters.getRequired("filters") /** - * The amount to charge for each unit outside of the allocation + * Bulk tiers for rating based on total usage volume * * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [cumulativeAllocation]. - * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("cumulative_allocation") - @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation - - /** - * Returns the raw JSON value of [groupAllocation]. - * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("group_allocation") - @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [filters]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [filters], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("filters") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _filters(): JsonField> = filters /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [tiers]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("unit_amount") + @JsonProperty("tiers") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _tiers(): JsonField> = tiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -10674,100 +10587,85 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() + * .filters() + * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null - private var groupingKey: JsonField? = null - private var unitAmount: JsonField? = null + private var filters: JsonField>? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + bulkWithFiltersConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.filters] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) - /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Adds a single [Filter] to [filters]. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } } - /** The event property used to group usage before applying allocations */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.tiers] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.tiers] with a well-typed `List` * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - /** The amount to charge for each unit outside of the allocation */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Adds a single [Tier] to [tiers]. * - * You should usually call [Builder.unitAmount] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -10793,41 +10691,35 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() + * .filters() + * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), - checkRequired("groupingKey", groupingKey), - checkRequired("unitAmount", unitAmount), + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() - groupingKey() - unitAmount() + filters().forEach { it.validate() } + tiers().forEach { it.validate() } validated = true } @@ -10847,251 +10739,139656 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && - groupingKey == other.groupingKey && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - additionalProperties, - ) - } + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - override fun hashCode(): Int = hashCode + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Event property value to match + * + * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey - companion object { + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** A builder for [Metadata]. */ - class Builder internal constructor() { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - private var additionalProperties: MutableMap = - mutableMapOf() + fun toBuilder() = Builder().from(this) - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + companion object { - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + 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 [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Metadata = apply { - if (validated) { - return@apply + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties } - validated = true + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * 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 = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - return other is CumulativeGroupedAllocation && - cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * 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 - private val hashCode: Int by lazy { - Objects.hash( - cadence, - cumulativeGroupedAllocationConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val ANNUAL = of("annual") - override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - class Percent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val percentConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmField val MONTHLY = of("monthly") - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException 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 packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Package]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException 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 matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Matrix]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException 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 thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException 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 consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException 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 totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @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 + * [ConsumptionTable]. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + 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 [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException 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 tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [TieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Optional = + hideZeroAmountTiers.getOptional("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException 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 groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [GroupedTiered]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + private var name: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { + this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException 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 packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [PackageWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException 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 packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @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 + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + 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 [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException 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 unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [UnitWithPercent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException 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 percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException 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 matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException 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 unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [UnitWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException 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 overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @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 + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + 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 [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException 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 bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [BulkWithProration]. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException 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 minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException 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 unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @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 + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + 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 [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException 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 minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException 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 scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException 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 scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException 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 scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @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 + * [ScalingFactor]. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + 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 [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException 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 perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @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 + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException 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 matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException 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 dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException 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 displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException 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 groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException 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 maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException 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 unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException 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 dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException 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 group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @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 + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + 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 [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (group.asKnown().isPresent) 1 else 0) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [DimensionValue]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MinimumComposite + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException 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 minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("minimum_composite") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [minimumCompositeConfig]. + * + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_composite_config") + @ExcludeMissing + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [MinimumComposite]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumComposite]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum_composite") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MinimumComposite]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumComposite = + MinimumComposite( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumComposite = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum_composite")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (minimumCompositeConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Optional = prorated.getOptional("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @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 + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + 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 [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumComposite && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @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 + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + 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 [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @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 + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + 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 [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @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 [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + 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 [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException 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 perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @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 + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @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 + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + 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 [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @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 + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + 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 [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException 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 adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @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 [RemoveAdjustment]. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + 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 [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (adjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException 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 priceId(): String = priceId.getRequired("price_id") + + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @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 [RemovePrice]. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + 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 [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (priceId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException 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 adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException 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 replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @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 [ReplaceAdjustment]. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + 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 [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(maximum) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException 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 replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): Optional = + allocationPrice.getOptional("allocation_price") + + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Optional = price.getOptional("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @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 [ReplacePrice]. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + licenseAllocationPrice = replacePrice.licenseAllocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ + fun price(minimumComposite: NewPlanMinimumCompositePrice) = + price(Price.ofMinimumComposite(minimumComposite)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + 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 [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } + planPhaseOrder() + price().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice + private constructor( + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: MinimumComposite? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): Unit = unit.getOrThrow("unit") + + fun asTiered(): Tiered = tiered.getOrThrow("tiered") + + fun asBulk(): Bulk = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): Package = package_.getOrThrow("package_") + + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): MatrixWithAllocation = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): MinimumComposite = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() + } + + override fun visitTiered(tiered: Tiered) { + tiered.validate() + } + + override fun visitBulk(bulk: Bulk) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: Package) { + package_.validate() + } + + override fun visitMatrix(matrix: Matrix) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitUnit(unit: Unit) = unit.validity() + + override fun visitTiered(tiered: Tiered) = tiered.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: Package) = package_.validity() + + override fun visitMatrix(matrix: Matrix) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocationPrice && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" + thresholdTotalAmount != null -> + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") + } + + companion object { + + @JvmStatic fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) + + @JvmStatic fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) + + @JvmStatic + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + LicenseAllocationPrice(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) + + @JvmStatic + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) + + @JvmStatic + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) + + @JvmStatic + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: Unit): T + + fun visitTiered(tiered: Tiered): T + + fun visitBulk(bulk: Bulk): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: Package): T + + fun visitMatrix(matrix: Matrix): T + + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T + + fun visitTieredPackage(tieredPackage: TieredPackage): T + + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T + + fun visitGroupedTiered(groupedTiered: GroupedTiered): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ): T + + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T + + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T + + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: UnitWithProration): T + + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T + + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T + + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T + + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ): T + + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: MinimumComposite): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. + * + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") + } + } + + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) + } + "minimum_composite" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) + } + } + + return LicenseAllocationPrice(_json = json) + } + } + + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { + + override fun serialize( + value: LicenseAllocationPrice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") + } + } + } + + class Unit + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException 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 unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Unit]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Unit]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Unit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Unit = + Unit( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Unit = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Tiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered pricing + * + * @throws OrbInvalidDataException 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 tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredConfig]. + * + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Tiered]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered") + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) + + /** + * Sets [Builder.tieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Tiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tiered = + Tiered( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tiered && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Bulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk pricing + * + * @throws OrbInvalidDataException 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 bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkConfig]. + * + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Bulk]. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Bulk]. */ + class Builder internal constructor() { + + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Bulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Bulk = apply { + if (validated) { + return@apply + } + + bulkConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Bulk && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @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 [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + 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 [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException 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 packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Package]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException 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 matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Matrix]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException 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 thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException 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 consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException 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 totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @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 + * [ConsumptionTable]. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + 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 [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException 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 tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [TieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Optional = + hideZeroAmountTiers.getOptional("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException 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 groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [GroupedTiered]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + private var name: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { + this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException 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 packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [PackageWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException 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 packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @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 + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + 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 [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException 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 unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [UnitWithPercent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException 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 percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException 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 matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException 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 unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [UnitWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException 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 overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @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 + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + 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 [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException 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 bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [BulkWithProration]. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException 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 minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException 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 unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @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 + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + 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 [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException 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 minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException 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 scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException 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 scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException 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 scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @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 + * [ScalingFactor]. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + 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 [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException 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 perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @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 + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException 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 matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException 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 dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException 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 displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException 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 groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException 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 maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException 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 unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException 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 dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException 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 group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @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 + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + 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 [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (group.asKnown().isPresent) 1 else 0) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [DimensionValue]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MinimumComposite + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -11128,6 +150425,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -11137,9 +150437,10 @@ private constructor( ) : this( cadence, itemId, + licenseAllocations, + minimumCompositeConfig, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11151,6 +150452,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -11174,12 +150476,34 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException 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 minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("percent") + * JsonValue.from("minimum_composite") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -11196,15 +150520,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11309,6 +150624,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -11347,22 +150670,33 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [licenseAllocations]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations /** - * Returns the raw JSON value of [percentConfig]. + * Returns the raw JSON value of [minimumCompositeConfig]. * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("percent_config") + @JsonProperty("minimum_composite_config") @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [billableMetricId]. @@ -11477,6 +150811,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11512,27 +150856,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of [MinimumComposite]. * * The following fields are required: * ```java * .cadence() * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() * .name() - * .percentConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [MinimumComposite]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -11550,31 +150897,36 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -11601,13 +150953,60 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("percent") + * JsonValue.from("minimum_composite") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11627,21 +151026,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11990,6 +151374,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12054,7 +151459,7 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [MinimumComposite]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12062,19 +151467,23 @@ private constructor( * ```java * .cadence() * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): MinimumComposite = + MinimumComposite( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12086,6 +151495,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -12094,20 +151504,21 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + fun validate(): MinimumComposite = apply { if (validated) { return@apply } cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("minimum_composite")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -12119,6 +151530,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -12142,9 +151554,11 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (minimumCompositeConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -12156,6 +151570,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -12318,39 +151733,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("amount") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * What percent of the component subtotals to charge + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + fun amount(): String = amount.getRequired("amount") /** - * Returns the raw JSON value of [percent]. + * The currency of the license allocation. * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("amount") @ExcludeMissing - fun _percent(): JsonField = percent + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -12368,40 +151828,90 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .percent() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } fun additionalProperties(additionalProperties: Map) = apply { @@ -12426,32 +151936,37 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [LicenseAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .percent() + * .amount() + * .currency() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): LicenseAllocation = apply { if (validated) { return@apply } - percent() + amount() + currency() + writeOffOverage() validated = true } @@ -12470,26 +151985,255 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash(amount, currency, writeOffOverage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Optional = prorated.getOptional("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @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 + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + 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 [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" } /** @@ -12608,12 +152352,13 @@ private constructor( return true } - return other is Percent && + return other is MinimumComposite && cadence == other.cadence && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12625,6 +152370,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12634,9 +152380,10 @@ private constructor( Objects.hash( cadence, itemId, + licenseAllocations, + minimumCompositeConfig, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12648,6 +152395,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12657,17 +152405,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class Percent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -12680,6 +152429,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12690,18 +152440,21 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") - @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -12738,6 +152491,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12746,10 +152502,11 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, itemId, + licenseAllocations, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12761,6 +152518,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12776,30 +152534,32 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for event_output pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12816,6 +152576,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -12920,6 +152689,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12949,16 +152726,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [eventOutputConfig]. - * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_output_config") - @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig - /** * Returns the raw JSON value of [itemId]. * @@ -12967,6 +152734,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -12975,6 +152752,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -13088,6 +152875,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -13123,27 +152920,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of [Percent]. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() * .itemId() + * .licenseAllocations() * .name() + * .percentConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [Percent]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") private var name: JsonField? = null + private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -13161,31 +152961,34 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -13200,21 +153003,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) - - /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -13227,13 +153015,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("percent") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13253,6 +153073,21 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -13601,6 +153436,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13665,27 +153521,31 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [Percent]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() * .itemId() + * .licenseAllocations() * .name() + * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): Percent = + Percent( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13697,6 +153557,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13705,20 +153566,21 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + fun validate(): Percent = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("percent")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -13730,6 +153592,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13752,10 +153615,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -13767,6 +153632,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13929,87 +153795,84 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") + @JsonProperty("amount") @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + fun amount(): String = amount.getRequired("amount") /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. + * The currency of the license allocation. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException 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 defaultUnitRate(): Optional = - defaultUnitRate.getOptional("default_unit_rate") + fun currency(): String = currency.getRequired("currency") /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. + * When True, overage beyond the allocation is written off. * * @throws OrbInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") /** - * Returns the raw JSON value of [unitRatingKey]. + * Returns the raw JSON value of [amount]. * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_rating_key") + @JsonProperty("amount") @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [defaultUnitRate]. + * Returns the raw JSON value of [currency]. * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * Unlike [currency], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("default_unit_rate") + @JsonProperty("currency") @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [writeOffOverage]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("write_off_overage") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -14027,98 +153890,274 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .unitRatingKey() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency } + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Alias for calling [Builder.defaultUnitRate] with - * `defaultUnitRate.orElse(null)`. + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. */ - fun defaultUnitRate(defaultUnitRate: Optional) = - defaultUnitRate(defaultUnitRate.getOrNull()) + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * You should usually call [Builder.defaultUnitRate] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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) } /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @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 { /** - * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` */ - fun groupingKey(groupingKey: Optional) = - groupingKey(groupingKey.getOrNull()) + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.percent] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.percent] with a well-typed [Double] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun percent(percent: JsonField) = apply { this.percent = percent } fun additionalProperties(additionalProperties: Map) = apply { @@ -14143,36 +154182,32 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [PercentConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .unitRatingKey() + * .percent() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + fun validate(): PercentConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() - groupingKey() + percent() validated = true } @@ -14191,36 +154226,26 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = - (if (unitRatingKey.asKnown().isPresent) 1 else 0) + - (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && + return other is PercentConfig && + percent == other.percent && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) + Objects.hash(percent, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" } /** @@ -14339,12 +154364,13 @@ private constructor( return true } - return other is EventOutput && + return other is Percent && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && itemId == other.itemId && + licenseAllocations == other.licenseAllocations && modelType == other.modelType && name == other.name && + percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -14356,6 +154382,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -14364,10 +154391,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, itemId, + licenseAllocations, modelType, name, + percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14379,1556 +154407,2154 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, ) } - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") - override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - override fun hashCode(): Int = hashCode + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException 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 adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun toBuilder() = Builder().from(this) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - companion object { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * 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 - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - private var validated: Boolean = false + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - /** - * 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 (adjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun hashCode(): Int = hashCode + fun toBuilder() = Builder().from(this) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + companion object { - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException 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 priceId(): String = priceId.getRequired("price_id") + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * 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 } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - fun toBuilder() = Builder().from(this) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - companion object { + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - priceId() - planPhaseOrder() - validated = true - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * 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 (priceId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException 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 adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException 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 replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun toBuilder() = Builder().from(this) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - companion object { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + private var validated: Boolean = false - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - private var validated: Boolean = 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + /** + * 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 - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { - /** - * 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 = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + @JvmField val ANNUAL = of("annual") - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + @JvmField val MONTHLY = of("monthly") - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + @JvmField val QUARTERLY = of("quarterly") - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + @JvmField val ONE_TIME = of("one_time") - fun minimum(): Optional = Optional.ofNullable(minimum) + @JvmField val CUSTOM = of("custom") - fun maximum(): Optional = Optional.ofNullable(maximum) + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun isMinimum(): Boolean = minimum != null + /** + * 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun isMaximum(): Boolean = maximum != null + /** + * 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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + private var validated: Boolean = false - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + known() + validated = true + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * 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 - fun _json(): Optional = Optional.ofNullable(_json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + return other is Cadence && value == other.value + } - private var validated: Boolean = false + override fun hashCode() = value.hashCode() - fun validate(): Adjustment = apply { - if (validated) { - return@apply + override fun toString() = value.toString() } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey - /** - * 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 = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + fun toBuilder() = Builder().from(this) - override fun unknown(json: JsonValue?) = 0 + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) - companion object { + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitMinimum(minimum: NewMinimum): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMaximum(maximum: NewMaximum): T + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + private var validated: Boolean = false - internal class Deserializer : BaseDeserializer(Adjustment::class) { + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - } - return Adjustment(_json = json) - } - } + /** + * 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 (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException 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 replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): Optional = - allocationPrice.getOptional("allocation_price") + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") - /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + /** + * 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 [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + companion object { - fun toBuilder() = Builder().from(this) + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - companion object { + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + amount() + currency() + writeOffOverage() + validated = true + } - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + /** + * 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + companion object { - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + private var additionalProperties: MutableMap = + mutableMapOf() - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + private var validated: Boolean = false - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + validated = true + } - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. - */ - fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = - price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ - fun price(minimumComposite: NewPlanMinimumCompositePrice) = - price(Price.ofMinimumComposite(minimumComposite)) + /** + * 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode(): Int = hashCode - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - private var validated: Boolean = false + override fun hashCode(): Int = hashCode - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - planPhaseOrder() - price().ifPresent { it.validate() } - validated = true } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) - /** New plan price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -17248,6 +157874,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -17306,6 +157933,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -17329,6 +157959,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -17488,6 +158119,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -17657,6 +158296,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -17730,6 +158379,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -17753,6 +158403,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -18171,6 +158822,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -18267,6 +158939,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -18300,6 +158973,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -18337,6 +159011,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -19334,6 +160009,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -19357,6 +160033,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -19366,7 +160043,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -19389,6 +160066,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -19448,6 +160126,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -19471,6 +160152,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -19630,6 +160312,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -19799,6 +160489,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -19874,6 +160574,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -19898,6 +160599,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -20318,6 +161020,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -20414,6 +161137,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -20447,6 +161171,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -20486,6 +161211,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -21200,6 +161926,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -21223,6 +161950,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -21232,7 +161960,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -21256,6 +161984,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -21316,6 +162045,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -21339,6 +162071,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -21500,6 +162233,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -21669,6 +162410,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -21746,6 +162497,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -21773,6 +162525,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -22200,6 +162953,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -22299,6 +163073,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -22332,6 +163107,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -22371,6 +163147,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -22993,6 +163770,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -23016,6 +163794,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -23025,7 +163804,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -23049,6 +163828,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23109,6 +163889,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23132,6 +163915,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23293,6 +164077,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -23462,6 +164254,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -23539,6 +164341,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -23566,6 +164369,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -23993,6 +164797,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -24092,6 +164917,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24125,6 +164951,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -24164,6 +164991,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -24793,6 +165621,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24816,6 +165645,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24825,7 +165655,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -24848,6 +165678,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24906,6 +165737,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24929,6 +165763,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -25087,6 +165922,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -25255,6 +166098,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25328,6 +166181,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25350,6 +166204,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -25768,6 +166623,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25864,6 +166740,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25897,6 +166774,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -25934,6 +166812,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -26403,6 +167282,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26426,6 +167306,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26435,7 +167316,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -26458,6 +167339,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26516,6 +167398,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26539,6 +167424,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26698,6 +167584,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -26866,6 +167760,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -26939,6 +167843,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -26961,6 +167866,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -27379,6 +168285,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27475,6 +168402,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27508,6 +168436,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -27545,6 +168474,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -28134,6 +169064,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -28157,6 +169088,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -28166,7 +169098,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -28178,6 +169110,7 @@ private constructor( return other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties @@ -28187,6 +169120,7 @@ private constructor( Objects.hash( replacesPriceId, allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties, @@ -28196,7 +169130,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt index b06b0d7cc..133b1d8a8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -32,6 +33,7 @@ private constructor( private val metadata: JsonField, private val name: JsonField, private val status: JsonField, + private val parameterDefinitions: JsonField>, private val additionalProperties: MutableMap, ) { @@ -45,7 +47,10 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - ) : this(id, description, item, metadata, name, status, mutableMapOf()) + @JsonProperty("parameter_definitions") + @ExcludeMissing + parameterDefinitions: JsonField> = JsonMissing.of(), + ) : this(id, description, item, metadata, name, status, parameterDefinitions, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -91,6 +96,13 @@ private constructor( */ fun status(): Status = status.getRequired("status") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun parameterDefinitions(): Optional> = + parameterDefinitions.getOptional("parameter_definitions") + /** * Returns the raw JSON value of [id]. * @@ -133,6 +145,16 @@ private constructor( */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + /** + * Returns the raw JSON value of [parameterDefinitions]. + * + * Unlike [parameterDefinitions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parameter_definitions") + @ExcludeMissing + fun _parameterDefinitions(): JsonField> = parameterDefinitions + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -172,6 +194,7 @@ private constructor( private var metadata: JsonField? = null private var name: JsonField? = null private var status: JsonField? = null + private var parameterDefinitions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -182,6 +205,7 @@ private constructor( metadata = billableMetric.metadata name = billableMetric.name status = billableMetric.status + parameterDefinitions = billableMetric.parameterDefinitions.map { it.toMutableList() } additionalProperties = billableMetric.additionalProperties.toMutableMap() } @@ -260,6 +284,40 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } + fun parameterDefinitions(parameterDefinitions: List?) = + parameterDefinitions(JsonField.ofNullable(parameterDefinitions)) + + /** + * Alias for calling [Builder.parameterDefinitions] with + * `parameterDefinitions.orElse(null)`. + */ + fun parameterDefinitions(parameterDefinitions: Optional>) = + parameterDefinitions(parameterDefinitions.getOrNull()) + + /** + * Sets [Builder.parameterDefinitions] to an arbitrary JSON value. + * + * You should usually call [Builder.parameterDefinitions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun parameterDefinitions(parameterDefinitions: JsonField>) = + apply { + this.parameterDefinitions = parameterDefinitions.map { it.toMutableList() } + } + + /** + * Adds a single [ParameterDefinition] to [parameterDefinitions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParameterDefinition(parameterDefinition: ParameterDefinition) = apply { + parameterDefinitions = + (parameterDefinitions ?: JsonField.of(mutableListOf())).also { + checkKnown("parameterDefinitions", it).add(parameterDefinition) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -304,6 +362,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("name", name), checkRequired("status", status), + (parameterDefinitions ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -321,6 +380,7 @@ private constructor( metadata().validate() name() status().validate() + parameterDefinitions().ifPresent { it.forEach { it.validate() } } validated = true } @@ -344,7 +404,8 @@ private constructor( (item.asKnown().getOrNull()?.validity() ?: 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + + (parameterDefinitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) /** * User specified key-value pairs for the resource. If not present, this defaults to an empty @@ -580,6 +641,107 @@ private constructor( override fun toString() = value.toString() } + class ParameterDefinition + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ParameterDefinition]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ParameterDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(parameterDefinition: ParameterDefinition) = apply { + additionalProperties = parameterDefinition.additionalProperties.toMutableMap() + } + + 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 [ParameterDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ParameterDefinition = + ParameterDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): ParameterDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ParameterDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ParameterDefinition{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -592,15 +754,25 @@ private constructor( metadata == other.metadata && name == other.name && status == other.status && + parameterDefinitions == other.parameterDefinitions && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, description, item, metadata, name, status, additionalProperties) + Objects.hash( + id, + description, + item, + metadata, + name, + status, + parameterDefinitions, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "BillableMetric{id=$id, description=$description, item=$item, metadata=$metadata, name=$name, status=$status, additionalProperties=$additionalProperties}" + "BillableMetric{id=$id, description=$description, item=$item, metadata=$metadata, name=$name, status=$status, parameterDefinitions=$parameterDefinitions, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index 6e3c85721..3f6180241 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -742,6 +742,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -790,6 +791,11 @@ private constructor( * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the * first discount in the list will be returned. If the list is empty, `None` will be * returned. + * + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = createdInvoice.discount().convert(MyClass.class); + * ``` */ @Deprecated("deprecated") @JsonProperty("discount") @@ -1840,6 +1846,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt new file mode 100644 index 000000000..a8bd589e1 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt @@ -0,0 +1,209 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint returns the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added or allocated from a + * subscription), this endpoint returns the invoices that were created to charge the customer for + * the credit block. For credit blocks with payment schedules spanning multiple periods (e.g., + * monthly payments over 12 months), multiple invoices will be returned. + * + * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices + * list is returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future releases. + * Please contact support before building production integrations against this endpoint.** + */ +class CreditBlockListInvoicesParams +private constructor( + private val blockId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun blockId(): Optional = Optional.ofNullable(blockId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CreditBlockListInvoicesParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CreditBlockListInvoicesParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditBlockListInvoicesParams]. */ + class Builder internal constructor() { + + private var blockId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(creditBlockListInvoicesParams: CreditBlockListInvoicesParams) = apply { + blockId = creditBlockListInvoicesParams.blockId + additionalHeaders = creditBlockListInvoicesParams.additionalHeaders.toBuilder() + additionalQueryParams = creditBlockListInvoicesParams.additionalQueryParams.toBuilder() + } + + fun blockId(blockId: String?) = apply { this.blockId = blockId } + + /** Alias for calling [Builder.blockId] with `blockId.orElse(null)`. */ + fun blockId(blockId: Optional) = blockId(blockId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CreditBlockListInvoicesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditBlockListInvoicesParams = + CreditBlockListInvoicesParams( + blockId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> blockId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditBlockListInvoicesParams && + blockId == other.blockId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(blockId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CreditBlockListInvoicesParams{blockId=$blockId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt new file mode 100644 index 000000000..2bdb76193 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt @@ -0,0 +1,2023 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CreditBlockListInvoicesResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val block: JsonField, + private val invoices: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("block") @ExcludeMissing block: JsonField = JsonMissing.of(), + @JsonProperty("invoices") + @ExcludeMissing + invoices: JsonField> = JsonMissing.of(), + ) : this(block, invoices, mutableMapOf()) + + /** + * The Credit Block resource models prepaid credits within Orb. + * + * @throws OrbInvalidDataException 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 block(): Block = block.getRequired("block") + + /** + * @throws OrbInvalidDataException 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 invoices(): List = invoices.getRequired("invoices") + + /** + * Returns the raw JSON value of [block]. + * + * Unlike [block], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("block") @ExcludeMissing fun _block(): JsonField = block + + /** + * Returns the raw JSON value of [invoices]. + * + * Unlike [invoices], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoices") @ExcludeMissing fun _invoices(): JsonField> = invoices + + @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 + * [CreditBlockListInvoicesResponse]. + * + * The following fields are required: + * ```java + * .block() + * .invoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditBlockListInvoicesResponse]. */ + class Builder internal constructor() { + + private var block: JsonField? = null + private var invoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditBlockListInvoicesResponse: CreditBlockListInvoicesResponse) = + apply { + block = creditBlockListInvoicesResponse.block + invoices = creditBlockListInvoicesResponse.invoices.map { it.toMutableList() } + additionalProperties = + creditBlockListInvoicesResponse.additionalProperties.toMutableMap() + } + + /** The Credit Block resource models prepaid credits within Orb. */ + fun block(block: Block) = block(JsonField.of(block)) + + /** + * Sets [Builder.block] to an arbitrary JSON value. + * + * You should usually call [Builder.block] with a well-typed [Block] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun block(block: JsonField) = apply { this.block = block } + + fun invoices(invoices: List) = invoices(JsonField.of(invoices)) + + /** + * Sets [Builder.invoices] to an arbitrary JSON value. + * + * You should usually call [Builder.invoices] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoices(invoices: JsonField>) = apply { + this.invoices = invoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [invoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInvoice(invoice: Invoice) = apply { + invoices = + (invoices ?: JsonField.of(mutableListOf())).also { + checkKnown("invoices", it).add(invoice) + } + } + + 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 [CreditBlockListInvoicesResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .block() + * .invoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse( + checkRequired("block", block), + checkRequired("invoices", invoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditBlockListInvoicesResponse = apply { + if (validated) { + return@apply + } + + block().validate() + invoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (block.asKnown().getOrNull()?.validity() ?: 0) + + (invoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** The Credit Block resource models prepaid credits within Orb. */ + class Block + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val balance: JsonField, + private val effectiveDate: JsonField, + private val expiryDate: JsonField, + private val filters: JsonField>, + private val maximumInitialBalance: JsonField, + private val metadata: JsonField, + private val perUnitCostBasis: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_initial_balance") + @ExcludeMissing + maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + perUnitCostBasis: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this( + id, + balance, + effectiveDate, + expiryDate, + filters, + maximumInitialBalance, + metadata, + perUnitCostBasis, + status, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException 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 balance(): Double = balance.getRequired("balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun effectiveDate(): Optional = effectiveDate.getOptional("effective_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiryDate(): Optional = expiryDate.getOptional("expiry_date") + + /** + * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maximumInitialBalance(): Optional = + maximumInitialBalance.getOptional("maximum_initial_balance") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException 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 metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun perUnitCostBasis(): Optional = + perUnitCostBasis.getOptional("per_unit_cost_basis") + + /** + * @throws OrbInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [balance]. + * + * Unlike [balance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [expiryDate]. + * + * Unlike [expiryDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [maximumInitialBalance]. + * + * Unlike [maximumInitialBalance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_initial_balance") + @ExcludeMissing + fun _maximumInitialBalance(): JsonField = maximumInitialBalance + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [perUnitCostBasis]. + * + * Unlike [perUnitCostBasis], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @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 [Block]. + * + * The following fields are required: + * ```java + * .id() + * .balance() + * .effectiveDate() + * .expiryDate() + * .filters() + * .maximumInitialBalance() + * .metadata() + * .perUnitCostBasis() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Block]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var balance: JsonField? = null + private var effectiveDate: JsonField? = null + private var expiryDate: JsonField? = null + private var filters: JsonField>? = null + private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(block: Block) = apply { + id = block.id + balance = block.balance + effectiveDate = block.effectiveDate + expiryDate = block.expiryDate + filters = block.filters.map { it.toMutableList() } + maximumInitialBalance = block.maximumInitialBalance + metadata = block.metadata + perUnitCostBasis = block.perUnitCostBasis + status = block.status + additionalProperties = block.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun balance(balance: Double) = balance(JsonField.of(balance)) + + /** + * Sets [Builder.balance] to an arbitrary JSON value. + * + * You should usually call [Builder.balance] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun balance(balance: JsonField) = apply { this.balance = balance } + + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + /** Alias for calling [Builder.effectiveDate] with `effectiveDate.orElse(null)`. */ + fun effectiveDate(effectiveDate: Optional) = + effectiveDate(effectiveDate.getOrNull()) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + /** Alias for calling [Builder.expiryDate] with `expiryDate.orElse(null)`. */ + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.getOrNull()) + + /** + * Sets [Builder.expiryDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + fun maximumInitialBalance(maximumInitialBalance: Double?) = + maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) + + /** + * Alias for [Builder.maximumInitialBalance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maximumInitialBalance(maximumInitialBalance: Double) = + maximumInitialBalance(maximumInitialBalance as Double?) + + /** + * Alias for calling [Builder.maximumInitialBalance] with + * `maximumInitialBalance.orElse(null)`. + */ + fun maximumInitialBalance(maximumInitialBalance: Optional) = + maximumInitialBalance(maximumInitialBalance.getOrNull()) + + /** + * Sets [Builder.maximumInitialBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumInitialBalance] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maximumInitialBalance(maximumInitialBalance: JsonField) = apply { + this.maximumInitialBalance = maximumInitialBalance + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + /** + * Alias for calling [Builder.perUnitCostBasis] with `perUnitCostBasis.orElse(null)`. + */ + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.getOrNull()) + + /** + * Sets [Builder.perUnitCostBasis] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitCostBasis] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + 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 [Block]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .balance() + * .effectiveDate() + * .expiryDate() + * .filters() + * .maximumInitialBalance() + * .metadata() + * .perUnitCostBasis() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Block = + Block( + checkRequired("id", id), + checkRequired("balance", balance), + checkRequired("effectiveDate", effectiveDate), + checkRequired("expiryDate", expiryDate), + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), + checkRequired("perUnitCostBasis", perUnitCostBasis), + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Block = apply { + if (validated) { + return@apply + } + + id() + balance() + effectiveDate() + expiryDate() + filters().forEach { it.validate() } + maximumInitialBalance() + metadata().validate() + perUnitCostBasis() + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (balance.asKnown().isPresent) 1 else 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException 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 field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException 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 operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException 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 values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @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 [Filter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + 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 [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @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 PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] 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 { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] 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) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @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 INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] 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 { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] 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) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Operator && 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 Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Status @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 ACTIVE = of("active") + + @JvmField val PENDING_PAYMENT = of("pending_payment") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PENDING_PAYMENT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + PENDING_PAYMENT, + /** + * An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + PENDING_PAYMENT -> Value.PENDING_PAYMENT + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PENDING_PAYMENT -> Known.PENDING_PAYMENT + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 Block && + id == other.id && + balance == other.balance && + effectiveDate == other.effectiveDate && + expiryDate == other.expiryDate && + filters == other.filters && + maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && + perUnitCostBasis == other.perUnitCostBasis && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + balance, + effectiveDate, + expiryDate, + filters, + maximumInitialBalance, + metadata, + perUnitCostBasis, + status, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Block{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val customer: JsonField, + private val invoiceNumber: JsonField, + private val status: JsonField, + private val subscription: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("invoice_number") + @ExcludeMissing + invoiceNumber: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + ) : this(id, customer, invoiceNumber, status, subscription, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException 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 customer(): CustomerMinified = customer.getRequired("customer") + + /** + * @throws OrbInvalidDataException 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 invoiceNumber(): String = invoiceNumber.getRequired("invoice_number") + + /** + * @throws OrbInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun subscription(): Optional = + subscription.getOptional("subscription") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [invoiceNumber]. + * + * Unlike [invoiceNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + @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 [Invoice]. + * + * The following fields are required: + * ```java + * .id() + * .customer() + * .invoiceNumber() + * .status() + * .subscription() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var customer: JsonField? = null + private var invoiceNumber: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + id = invoice.id + customer = invoice.customer + invoiceNumber = invoice.invoiceNumber + status = invoice.status + subscription = invoice.subscription + additionalProperties = invoice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun customer(customer: CustomerMinified) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [CustomerMinified] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + fun invoiceNumber(invoiceNumber: String) = invoiceNumber(JsonField.of(invoiceNumber)) + + /** + * Sets [Builder.invoiceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceNumber(invoiceNumber: JsonField) = apply { + this.invoiceNumber = invoiceNumber + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: SubscriptionMinified?) = + subscription(JsonField.ofNullable(subscription)) + + /** Alias for calling [Builder.subscription] with `subscription.orElse(null)`. */ + fun subscription(subscription: Optional) = + subscription(subscription.getOrNull()) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed + * [SubscriptionMinified] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + 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 [Invoice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .customer() + * .invoiceNumber() + * .status() + * .subscription() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Invoice = + Invoice( + checkRequired("id", id), + checkRequired("customer", customer), + checkRequired("invoiceNumber", invoiceNumber), + checkRequired("status", status), + checkRequired("subscription", subscription), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Invoice = apply { + if (validated) { + return@apply + } + + id() + customer().validate() + invoiceNumber() + status().validate() + subscription().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceNumber.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + class Status @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 ISSUED = of("issued") + + @JvmField val PAID = of("paid") + + @JvmField val SYNCED = of("synced") + + @JvmField val VOID = of("void") + + @JvmField val DRAFT = of("draft") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + /** + * An enum member indicating that [Status] 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) { + ISSUED -> Value.ISSUED + PAID -> Value.PAID + SYNCED -> Value.SYNCED + VOID -> Value.VOID + DRAFT -> Value.DRAFT + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ISSUED -> Known.ISSUED + PAID -> Known.PAID + SYNCED -> Known.SYNCED + VOID -> Known.VOID + DRAFT -> Known.DRAFT + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 Invoice && + id == other.id && + customer == other.customer && + invoiceNumber == other.invoiceNumber && + status == other.status && + subscription == other.subscription && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, customer, invoiceNumber, status, subscription, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{id=$id, customer=$customer, invoiceNumber=$invoiceNumber, status=$status, subscription=$subscription, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditBlockListInvoicesResponse && + block == other.block && + invoices == other.invoices && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(block, invoices, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditBlockListInvoicesResponse{block=$block, invoices=$invoices, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt index bbc248c0e..6f4dce4dc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt @@ -31,6 +31,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -52,6 +53,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -63,6 +65,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -105,6 +108,16 @@ private constructor( fun maximumInitialBalance(): Optional = maximumInitialBalance.getOptional("maximum_initial_balance") + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException 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 metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -166,6 +179,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -208,6 +228,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -224,6 +245,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -236,6 +258,7 @@ private constructor( expiryDate = creditBlockRetrieveResponse.expiryDate filters = creditBlockRetrieveResponse.filters.map { it.toMutableList() } maximumInitialBalance = creditBlockRetrieveResponse.maximumInitialBalance + metadata = creditBlockRetrieveResponse.metadata perUnitCostBasis = creditBlockRetrieveResponse.perUnitCostBasis status = creditBlockRetrieveResponse.status additionalProperties = creditBlockRetrieveResponse.additionalProperties.toMutableMap() @@ -349,6 +372,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -409,6 +448,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -423,6 +463,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -442,6 +483,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -468,6 +510,7 @@ private constructor( (if (expiryDate.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) @@ -1001,6 +1044,110 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1137,6 +1284,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1150,6 +1298,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1159,5 +1308,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreditBlockRetrieveResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CreditBlockRetrieveResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt index 856fcb04e..f502ea5b9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -408,6 +408,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1248,6 +1249,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index 702f26ece..45e7624f3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -308,6 +308,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1167,6 +1168,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1752,6 +1754,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -2686,6 +2689,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index db2e67796..3bc6f297f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -78,7 +78,13 @@ import kotlin.jvm.optionals.getOrNull * pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for * the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying the - * cost basis with the number of credit units added. + * cost basis with the number of credit units added. If you invoice or handle payment of credits + * outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the `invoice_settings` to + * `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required to + * determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb @@ -1786,6 +1792,7 @@ private constructor( private val customDueDate: JsonField, private val invoiceDate: JsonField, private val itemId: JsonField, + private val markAsPaid: JsonField, private val memo: JsonField, private val netTerms: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1806,6 +1813,9 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("mark_as_paid") + @ExcludeMissing + markAsPaid: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @@ -1820,6 +1830,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -1865,6 +1876,14 @@ private constructor( */ fun itemId(): Optional = itemId.getOptional("item_id") + /** + * If true, the new credits purchase invoice will be marked as paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun markAsPaid(): Optional = markAsPaid.getOptional("mark_as_paid") + /** * An optional memo to display on the invoice. * @@ -1878,7 +1897,7 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured due * date calculation method. A value of '0' here represents that the invoice is due * on issue, whereas a value of '30' represents that the customer has 30 days to pay - * the invoice. Do not set this field if you want to set a custom due date. + * the invoice. You must set either `net_terms` or `custom_due_date`, but not both. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1933,6 +1952,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [markAsPaid]. + * + * Unlike [markAsPaid], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mark_as_paid") + @ExcludeMissing + fun _markAsPaid(): JsonField = markAsPaid + /** * Returns the raw JSON value of [memo]. * @@ -1993,6 +2022,7 @@ private constructor( private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var itemId: JsonField = JsonMissing.of() + private var markAsPaid: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var netTerms: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() @@ -2004,6 +2034,7 @@ private constructor( customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate itemId = invoiceSettings.itemId + markAsPaid = invoiceSettings.markAsPaid memo = invoiceSettings.memo netTerms = invoiceSettings.netTerms requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment @@ -2109,6 +2140,20 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** If true, the new credits purchase invoice will be marked as paid. */ + fun markAsPaid(markAsPaid: Boolean) = markAsPaid(JsonField.of(markAsPaid)) + + /** + * Sets [Builder.markAsPaid] to an arbitrary JSON value. + * + * You should usually call [Builder.markAsPaid] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun markAsPaid(markAsPaid: JsonField) = apply { + this.markAsPaid = markAsPaid + } + /** An optional memo to display on the invoice. */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) @@ -2129,8 +2174,8 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured * due date calculation method. A value of '0' here represents that the invoice * is due on issue, whereas a value of '30' represents that the customer has 30 - * days to pay the invoice. Do not set this field if you want to set a custom - * due date. + * days to pay the invoice. You must set either `net_terms` or + * `custom_due_date`, but not both. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) @@ -2212,6 +2257,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2230,6 +2276,7 @@ private constructor( customDueDate().ifPresent { it.validate() } invoiceDate().ifPresent { it.validate() } itemId() + markAsPaid() memo() netTerms() requireSuccessfulPayment() @@ -2256,6 +2303,7 @@ private constructor( (customDueDate.asKnown().getOrNull()?.validity() ?: 0) + (invoiceDate.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (markAsPaid.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) @@ -2631,6 +2679,7 @@ private constructor( customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && itemId == other.itemId && + markAsPaid == other.markAsPaid && memo == other.memo && netTerms == other.netTerms && requireSuccessfulPayment == other.requireSuccessfulPayment && @@ -2643,6 +2692,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2653,7 +2703,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, markAsPaid=$markAsPaid, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 9b94f9852..1e216e288 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -78,7 +78,13 @@ import kotlin.jvm.optionals.getOrNull * pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for * the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying the - * cost basis with the number of credit units added. + * cost basis with the number of credit units added. If you invoice or handle payment of credits + * outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the `invoice_settings` to + * `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required to + * determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb @@ -1778,6 +1784,7 @@ private constructor( private val customDueDate: JsonField, private val invoiceDate: JsonField, private val itemId: JsonField, + private val markAsPaid: JsonField, private val memo: JsonField, private val netTerms: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1798,6 +1805,9 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("mark_as_paid") + @ExcludeMissing + markAsPaid: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @@ -1812,6 +1822,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -1857,6 +1868,14 @@ private constructor( */ fun itemId(): Optional = itemId.getOptional("item_id") + /** + * If true, the new credits purchase invoice will be marked as paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun markAsPaid(): Optional = markAsPaid.getOptional("mark_as_paid") + /** * An optional memo to display on the invoice. * @@ -1870,7 +1889,7 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured due * date calculation method. A value of '0' here represents that the invoice is due * on issue, whereas a value of '30' represents that the customer has 30 days to pay - * the invoice. Do not set this field if you want to set a custom due date. + * the invoice. You must set either `net_terms` or `custom_due_date`, but not both. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1925,6 +1944,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [markAsPaid]. + * + * Unlike [markAsPaid], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mark_as_paid") + @ExcludeMissing + fun _markAsPaid(): JsonField = markAsPaid + /** * Returns the raw JSON value of [memo]. * @@ -1985,6 +2014,7 @@ private constructor( private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var itemId: JsonField = JsonMissing.of() + private var markAsPaid: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var netTerms: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() @@ -1996,6 +2026,7 @@ private constructor( customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate itemId = invoiceSettings.itemId + markAsPaid = invoiceSettings.markAsPaid memo = invoiceSettings.memo netTerms = invoiceSettings.netTerms requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment @@ -2101,6 +2132,20 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** If true, the new credits purchase invoice will be marked as paid. */ + fun markAsPaid(markAsPaid: Boolean) = markAsPaid(JsonField.of(markAsPaid)) + + /** + * Sets [Builder.markAsPaid] to an arbitrary JSON value. + * + * You should usually call [Builder.markAsPaid] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun markAsPaid(markAsPaid: JsonField) = apply { + this.markAsPaid = markAsPaid + } + /** An optional memo to display on the invoice. */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) @@ -2121,8 +2166,8 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured * due date calculation method. A value of '0' here represents that the invoice * is due on issue, whereas a value of '30' represents that the customer has 30 - * days to pay the invoice. Do not set this field if you want to set a custom - * due date. + * days to pay the invoice. You must set either `net_terms` or + * `custom_due_date`, but not both. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) @@ -2204,6 +2249,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2222,6 +2268,7 @@ private constructor( customDueDate().ifPresent { it.validate() } invoiceDate().ifPresent { it.validate() } itemId() + markAsPaid() memo() netTerms() requireSuccessfulPayment() @@ -2248,6 +2295,7 @@ private constructor( (customDueDate.asKnown().getOrNull()?.validity() ?: 0) + (invoiceDate.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (markAsPaid.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) @@ -2623,6 +2671,7 @@ private constructor( customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && itemId == other.itemId && + markAsPaid == other.markAsPaid && memo == other.memo && netTerms == other.netTerms && requireSuccessfulPayment == other.requireSuccessfulPayment && @@ -2635,6 +2684,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2645,7 +2695,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, markAsPaid=$markAsPaid, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt index f60e9739a..ffcbecf5d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt @@ -38,10 +38,8 @@ import kotlin.jvm.optionals.getOrNull * * As usage for a customer is reported into Orb, credits may be deducted according to the customer's * plan configuration. An automated deduction of this type will result in a ledger entry, also with - * a starting and ending balance. In order to provide better tracing capabilities for automatic - * deductions, Orb always associates each automatic deduction with the `event_id` at the time of - * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are - * never deducted without an associated usage event. + * a starting and ending balance. Each day's usage for a particular price, invoice, and block will + * be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring credit * block* first in order to ensure that all credits are utilized appropriately. As an example, if diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt index b6a021be9..b3cf8fcaf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt @@ -38,10 +38,8 @@ import kotlin.jvm.optionals.getOrNull * * As usage for a customer is reported into Orb, credits may be deducted according to the customer's * plan configuration. An automated deduction of this type will result in a ledger entry, also with - * a starting and ending balance. In order to provide better tracing capabilities for automatic - * deductions, Orb always associates each automatic deduction with the `event_id` at the time of - * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are - * never deducted without an associated usage event. + * a starting and ending balance. Each day's usage for a particular price, invoice, and block will + * be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring credit * block* first in order to ensure that all credits are utilized appropriately. As an example, if diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt index a4a0cf202..bb5177829 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt @@ -5,6 +5,8 @@ package com.withorb.api.models import com.withorb.api.core.Params import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -17,12 +19,21 @@ import kotlin.jvm.optionals.getOrNull * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ class CustomerCreditListByExternalIdParams private constructor( private val externalCustomerId: String?, private val currency: String?, private val cursor: String?, + private val effectiveDateGt: OffsetDateTime?, + private val effectiveDateGte: OffsetDateTime?, + private val effectiveDateLt: OffsetDateTime?, + private val effectiveDateLte: OffsetDateTime?, private val includeAllBlocks: Boolean?, private val limit: Long?, private val additionalHeaders: Headers, @@ -40,6 +51,14 @@ private constructor( */ fun cursor(): Optional = Optional.ofNullable(cursor) + fun effectiveDateGt(): Optional = Optional.ofNullable(effectiveDateGt) + + fun effectiveDateGte(): Optional = Optional.ofNullable(effectiveDateGte) + + fun effectiveDateLt(): Optional = Optional.ofNullable(effectiveDateLt) + + fun effectiveDateLte(): Optional = Optional.ofNullable(effectiveDateLte) + /** * If set to True, all expired and depleted blocks, as well as active block will be returned. */ @@ -73,6 +92,10 @@ private constructor( private var externalCustomerId: String? = null private var currency: String? = null private var cursor: String? = null + private var effectiveDateGt: OffsetDateTime? = null + private var effectiveDateGte: OffsetDateTime? = null + private var effectiveDateLt: OffsetDateTime? = null + private var effectiveDateLte: OffsetDateTime? = null private var includeAllBlocks: Boolean? = null private var limit: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -85,6 +108,10 @@ private constructor( externalCustomerId = customerCreditListByExternalIdParams.externalCustomerId currency = customerCreditListByExternalIdParams.currency cursor = customerCreditListByExternalIdParams.cursor + effectiveDateGt = customerCreditListByExternalIdParams.effectiveDateGt + effectiveDateGte = customerCreditListByExternalIdParams.effectiveDateGte + effectiveDateLt = customerCreditListByExternalIdParams.effectiveDateLt + effectiveDateLte = customerCreditListByExternalIdParams.effectiveDateLte includeAllBlocks = customerCreditListByExternalIdParams.includeAllBlocks limit = customerCreditListByExternalIdParams.limit additionalHeaders = customerCreditListByExternalIdParams.additionalHeaders.toBuilder() @@ -117,6 +144,38 @@ private constructor( /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + fun effectiveDateGt(effectiveDateGt: OffsetDateTime?) = apply { + this.effectiveDateGt = effectiveDateGt + } + + /** Alias for calling [Builder.effectiveDateGt] with `effectiveDateGt.orElse(null)`. */ + fun effectiveDateGt(effectiveDateGt: Optional) = + effectiveDateGt(effectiveDateGt.getOrNull()) + + fun effectiveDateGte(effectiveDateGte: OffsetDateTime?) = apply { + this.effectiveDateGte = effectiveDateGte + } + + /** Alias for calling [Builder.effectiveDateGte] with `effectiveDateGte.orElse(null)`. */ + fun effectiveDateGte(effectiveDateGte: Optional) = + effectiveDateGte(effectiveDateGte.getOrNull()) + + fun effectiveDateLt(effectiveDateLt: OffsetDateTime?) = apply { + this.effectiveDateLt = effectiveDateLt + } + + /** Alias for calling [Builder.effectiveDateLt] with `effectiveDateLt.orElse(null)`. */ + fun effectiveDateLt(effectiveDateLt: Optional) = + effectiveDateLt(effectiveDateLt.getOrNull()) + + fun effectiveDateLte(effectiveDateLte: OffsetDateTime?) = apply { + this.effectiveDateLte = effectiveDateLte + } + + /** Alias for calling [Builder.effectiveDateLte] with `effectiveDateLte.orElse(null)`. */ + fun effectiveDateLte(effectiveDateLte: Optional) = + effectiveDateLte(effectiveDateLte.getOrNull()) + /** * If set to True, all expired and depleted blocks, as well as active block will be * returned. @@ -258,6 +317,10 @@ private constructor( externalCustomerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders.build(), @@ -278,6 +341,18 @@ private constructor( .apply { currency?.let { put("currency", it) } cursor?.let { put("cursor", it) } + effectiveDateGt?.let { + put("effective_date[gt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateGte?.let { + put("effective_date[gte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLt?.let { + put("effective_date[lt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLte?.let { + put("effective_date[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } includeAllBlocks?.let { put("include_all_blocks", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) @@ -293,6 +368,10 @@ private constructor( externalCustomerId == other.externalCustomerId && currency == other.currency && cursor == other.cursor && + effectiveDateGt == other.effectiveDateGt && + effectiveDateGte == other.effectiveDateGte && + effectiveDateLt == other.effectiveDateLt && + effectiveDateLte == other.effectiveDateLte && includeAllBlocks == other.includeAllBlocks && limit == other.limit && additionalHeaders == other.additionalHeaders && @@ -304,6 +383,10 @@ private constructor( externalCustomerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders, @@ -311,5 +394,5 @@ private constructor( ) override fun toString() = - "CustomerCreditListByExternalIdParams{externalCustomerId=$externalCustomerId, currency=$currency, cursor=$cursor, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditListByExternalIdParams{externalCustomerId=$externalCustomerId, currency=$currency, cursor=$cursor, effectiveDateGt=$effectiveDateGt, effectiveDateGte=$effectiveDateGte, effectiveDateLt=$effectiveDateLt, effectiveDateLte=$effectiveDateLte, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index f1e619c12..5f84ae0e0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -30,6 +30,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -51,6 +52,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -62,6 +64,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -104,6 +107,16 @@ private constructor( fun maximumInitialBalance(): Optional = maximumInitialBalance.getOptional("maximum_initial_balance") + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException 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 metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -165,6 +178,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -208,6 +228,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -224,6 +245,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -238,6 +260,7 @@ private constructor( expiryDate = customerCreditListByExternalIdResponse.expiryDate filters = customerCreditListByExternalIdResponse.filters.map { it.toMutableList() } maximumInitialBalance = customerCreditListByExternalIdResponse.maximumInitialBalance + metadata = customerCreditListByExternalIdResponse.metadata perUnitCostBasis = customerCreditListByExternalIdResponse.perUnitCostBasis status = customerCreditListByExternalIdResponse.status additionalProperties = @@ -352,6 +375,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -412,6 +451,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -426,6 +466,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -445,6 +486,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -471,6 +513,7 @@ private constructor( (if (expiryDate.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) @@ -981,6 +1024,110 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1117,6 +1264,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1130,6 +1278,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1139,5 +1288,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt index 1819ee0c9..06a399edf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt @@ -5,6 +5,8 @@ package com.withorb.api.models import com.withorb.api.core.Params import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -17,12 +19,21 @@ import kotlin.jvm.optionals.getOrNull * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ class CustomerCreditListParams private constructor( private val customerId: String?, private val currency: String?, private val cursor: String?, + private val effectiveDateGt: OffsetDateTime?, + private val effectiveDateGte: OffsetDateTime?, + private val effectiveDateLt: OffsetDateTime?, + private val effectiveDateLte: OffsetDateTime?, private val includeAllBlocks: Boolean?, private val limit: Long?, private val additionalHeaders: Headers, @@ -40,6 +51,14 @@ private constructor( */ fun cursor(): Optional = Optional.ofNullable(cursor) + fun effectiveDateGt(): Optional = Optional.ofNullable(effectiveDateGt) + + fun effectiveDateGte(): Optional = Optional.ofNullable(effectiveDateGte) + + fun effectiveDateLt(): Optional = Optional.ofNullable(effectiveDateLt) + + fun effectiveDateLte(): Optional = Optional.ofNullable(effectiveDateLte) + /** * If set to True, all expired and depleted blocks, as well as active block will be returned. */ @@ -70,6 +89,10 @@ private constructor( private var customerId: String? = null private var currency: String? = null private var cursor: String? = null + private var effectiveDateGt: OffsetDateTime? = null + private var effectiveDateGte: OffsetDateTime? = null + private var effectiveDateLt: OffsetDateTime? = null + private var effectiveDateLte: OffsetDateTime? = null private var includeAllBlocks: Boolean? = null private var limit: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -80,6 +103,10 @@ private constructor( customerId = customerCreditListParams.customerId currency = customerCreditListParams.currency cursor = customerCreditListParams.cursor + effectiveDateGt = customerCreditListParams.effectiveDateGt + effectiveDateGte = customerCreditListParams.effectiveDateGte + effectiveDateLt = customerCreditListParams.effectiveDateLt + effectiveDateLte = customerCreditListParams.effectiveDateLte includeAllBlocks = customerCreditListParams.includeAllBlocks limit = customerCreditListParams.limit additionalHeaders = customerCreditListParams.additionalHeaders.toBuilder() @@ -106,6 +133,38 @@ private constructor( /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + fun effectiveDateGt(effectiveDateGt: OffsetDateTime?) = apply { + this.effectiveDateGt = effectiveDateGt + } + + /** Alias for calling [Builder.effectiveDateGt] with `effectiveDateGt.orElse(null)`. */ + fun effectiveDateGt(effectiveDateGt: Optional) = + effectiveDateGt(effectiveDateGt.getOrNull()) + + fun effectiveDateGte(effectiveDateGte: OffsetDateTime?) = apply { + this.effectiveDateGte = effectiveDateGte + } + + /** Alias for calling [Builder.effectiveDateGte] with `effectiveDateGte.orElse(null)`. */ + fun effectiveDateGte(effectiveDateGte: Optional) = + effectiveDateGte(effectiveDateGte.getOrNull()) + + fun effectiveDateLt(effectiveDateLt: OffsetDateTime?) = apply { + this.effectiveDateLt = effectiveDateLt + } + + /** Alias for calling [Builder.effectiveDateLt] with `effectiveDateLt.orElse(null)`. */ + fun effectiveDateLt(effectiveDateLt: Optional) = + effectiveDateLt(effectiveDateLt.getOrNull()) + + fun effectiveDateLte(effectiveDateLte: OffsetDateTime?) = apply { + this.effectiveDateLte = effectiveDateLte + } + + /** Alias for calling [Builder.effectiveDateLte] with `effectiveDateLte.orElse(null)`. */ + fun effectiveDateLte(effectiveDateLte: Optional) = + effectiveDateLte(effectiveDateLte.getOrNull()) + /** * If set to True, all expired and depleted blocks, as well as active block will be * returned. @@ -247,6 +306,10 @@ private constructor( customerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders.build(), @@ -267,6 +330,18 @@ private constructor( .apply { currency?.let { put("currency", it) } cursor?.let { put("cursor", it) } + effectiveDateGt?.let { + put("effective_date[gt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateGte?.let { + put("effective_date[gte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLt?.let { + put("effective_date[lt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLte?.let { + put("effective_date[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } includeAllBlocks?.let { put("include_all_blocks", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) @@ -282,6 +357,10 @@ private constructor( customerId == other.customerId && currency == other.currency && cursor == other.cursor && + effectiveDateGt == other.effectiveDateGt && + effectiveDateGte == other.effectiveDateGte && + effectiveDateLt == other.effectiveDateLt && + effectiveDateLte == other.effectiveDateLte && includeAllBlocks == other.includeAllBlocks && limit == other.limit && additionalHeaders == other.additionalHeaders && @@ -293,6 +372,10 @@ private constructor( customerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders, @@ -300,5 +383,5 @@ private constructor( ) override fun toString() = - "CustomerCreditListParams{customerId=$customerId, currency=$currency, cursor=$cursor, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditListParams{customerId=$customerId, currency=$currency, cursor=$cursor, effectiveDateGt=$effectiveDateGt, effectiveDateGte=$effectiveDateGte, effectiveDateLt=$effectiveDateLt, effectiveDateLte=$effectiveDateLte, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index 516d91b45..a719d324b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -30,6 +30,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -51,6 +52,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -62,6 +64,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -104,6 +107,16 @@ private constructor( fun maximumInitialBalance(): Optional = maximumInitialBalance.getOptional("maximum_initial_balance") + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException 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 metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -165,6 +178,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -207,6 +227,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -223,6 +244,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -235,6 +257,7 @@ private constructor( expiryDate = customerCreditListResponse.expiryDate filters = customerCreditListResponse.filters.map { it.toMutableList() } maximumInitialBalance = customerCreditListResponse.maximumInitialBalance + metadata = customerCreditListResponse.metadata perUnitCostBasis = customerCreditListResponse.perUnitCostBasis status = customerCreditListResponse.status additionalProperties = customerCreditListResponse.additionalProperties.toMutableMap() @@ -348,6 +371,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -408,6 +447,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -422,6 +462,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -441,6 +482,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -467,6 +509,7 @@ private constructor( (if (expiryDate.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) @@ -977,6 +1020,110 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1113,6 +1260,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1126,6 +1274,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1135,5 +1284,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt index 09bcbb95c..fd2504cf5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt @@ -123,6 +123,7 @@ import kotlin.jvm.optionals.getOrNull * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1328,6 +1329,8 @@ private constructor( @JvmField val PH_TIN = of("ph_tin") + @JvmField val PL_NIP = of("pl_nip") + @JvmField val RO_TIN = of("ro_tin") @JvmField val RS_PIB = of("rs_pib") @@ -1470,6 +1473,7 @@ private constructor( OM_VAT, PE_RUC, PH_TIN, + PL_NIP, RO_TIN, RS_PIB, RU_INN, @@ -1592,6 +1596,7 @@ private constructor( OM_VAT, PE_RUC, PH_TIN, + PL_NIP, RO_TIN, RS_PIB, RU_INN, @@ -1715,6 +1720,7 @@ private constructor( OM_VAT -> Value.OM_VAT PE_RUC -> Value.PE_RUC PH_TIN -> Value.PH_TIN + PL_NIP -> Value.PL_NIP RO_TIN -> Value.RO_TIN RS_PIB -> Value.RS_PIB RU_INN -> Value.RU_INN @@ -1838,6 +1844,7 @@ private constructor( OM_VAT -> Known.OM_VAT PE_RUC -> Known.PE_RUC PH_TIN -> Known.PH_TIN + PL_NIP -> Known.PL_NIP RO_TIN -> Known.RO_TIN RS_PIB -> Known.RS_PIB RU_INN -> Known.RU_INN diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index dec9f8ada..62fdcfc3e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -93,8 +93,9 @@ private constructor( fun billingAddress(): Optional = body.billingAddress() /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only be + * set if the customer does not already have a currency configured. If not set at creation or + * update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -307,6 +308,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -685,8 +687,9 @@ private constructor( } /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = apply { body.currency(currency) } @@ -1162,6 +1165,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1508,8 +1512,9 @@ private constructor( fun billingAddress(): Optional = billingAddress.getOptional("billing_address") /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1728,6 +1733,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -2155,8 +2161,9 @@ private constructor( } /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set - * at creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can + * only be set if the customer does not already have a currency configured. If not set + * at creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -2642,6 +2649,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index 971b2f8ad..aa5464730 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -36,8 +36,9 @@ import kotlin.jvm.optionals.getOrNull /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, * `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, - * `billing_address`, and `additional_emails` of an existing customer. Other fields on a customer - * are currently immutable. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` can + * only be set if it has not already been set on the customer. Other fields on a customer are + * currently immutable. */ class CustomerUpdateParams private constructor( @@ -94,8 +95,9 @@ private constructor( fun billingAddress(): Optional = body.billingAddress() /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only be + * set if the customer does not already have a currency configured. If not set at creation or + * update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -308,6 +310,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -681,8 +684,9 @@ private constructor( } /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = apply { body.currency(currency) } @@ -1158,6 +1162,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1504,8 +1509,9 @@ private constructor( fun billingAddress(): Optional = billingAddress.getOptional("billing_address") /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1724,6 +1730,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -2151,8 +2158,9 @@ private constructor( } /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set - * at creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can + * only be set if the customer does not already have a currency configured. If not set + * at creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -2638,6 +2646,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index c1f6102c2..75786b486 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -403,6 +403,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -450,6 +451,11 @@ private constructor( /** * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the * first discount in the list will be returned. If the list is empty, `None` will be returned. + * + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = invoice.discount().convert(MyClass.class); + * ``` */ @Deprecated("deprecated") @JsonProperty("discount") @@ -1446,6 +1452,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 438ed64b2..28d9e5853 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -67,6 +67,15 @@ private constructor( */ fun lineItems(): List = body.lineItems() + /** + * Determines whether this invoice will automatically attempt to charge a saved payment method, + * if any. If not specified, the invoice inherits the customer's auto_collection setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoCollection(): Optional = body.autoCollection() + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -163,6 +172,13 @@ private constructor( */ fun _lineItems(): JsonField> = body._lineItems() + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoCollection(): JsonField = body._autoCollection() + /** * Returns the raw JSON value of [customerId]. * @@ -267,8 +283,8 @@ private constructor( * - [currency] * - [invoiceDate] * - [lineItems] + * - [autoCollection] * - [customerId] - * - [discount] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -321,6 +337,35 @@ private constructor( */ fun addLineItem(lineItem: LineItem) = apply { body.addLineItem(lineItem) } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + */ + fun autoCollection(autoCollection: Boolean?) = apply { body.autoCollection(autoCollection) } + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -680,6 +725,7 @@ private constructor( private val currency: JsonField, private val invoiceDate: JsonField, private val lineItems: JsonField>, + private val autoCollection: JsonField, private val customerId: JsonField, private val discount: JsonField, private val dueDate: JsonField, @@ -702,6 +748,9 @@ private constructor( @JsonProperty("line_items") @ExcludeMissing lineItems: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), @JsonProperty("customer_id") @ExcludeMissing customerId: JsonField = JsonMissing.of(), @@ -726,6 +775,7 @@ private constructor( currency, invoiceDate, lineItems, + autoCollection, customerId, discount, dueDate, @@ -760,6 +810,16 @@ private constructor( */ fun lineItems(): List = lineItems.getRequired("line_items") + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Optional = autoCollection.getOptional("auto_collection") + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -861,6 +921,16 @@ private constructor( @ExcludeMissing fun _lineItems(): JsonField> = lineItems + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + /** * Returns the raw JSON value of [customerId]. * @@ -958,6 +1028,7 @@ private constructor( private var currency: JsonField? = null private var invoiceDate: JsonField? = null private var lineItems: JsonField>? = null + private var autoCollection: JsonField = JsonMissing.of() private var customerId: JsonField = JsonMissing.of() private var discount: JsonField = JsonMissing.of() private var dueDate: JsonField = JsonMissing.of() @@ -973,6 +1044,7 @@ private constructor( currency = body.currency invoiceDate = body.invoiceDate lineItems = body.lineItems.map { it.toMutableList() } + autoCollection = body.autoCollection customerId = body.customerId discount = body.discount dueDate = body.dueDate @@ -1041,6 +1113,36 @@ private constructor( } } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -1307,6 +1409,7 @@ private constructor( checkRequired("currency", currency), checkRequired("invoiceDate", invoiceDate), checkRequired("lineItems", lineItems).map { it.toImmutable() }, + autoCollection, customerId, discount, dueDate, @@ -1329,6 +1432,7 @@ private constructor( currency() invoiceDate() lineItems().forEach { it.validate() } + autoCollection() customerId() discount().ifPresent { it.validate() } dueDate().ifPresent { it.validate() } @@ -1359,6 +1463,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (invoiceDate.asKnown().isPresent) 1 else 0) + (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + (if (customerId.asKnown().isPresent) 1 else 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + (dueDate.asKnown().getOrNull()?.validity() ?: 0) + @@ -1377,6 +1482,7 @@ private constructor( currency == other.currency && invoiceDate == other.invoiceDate && lineItems == other.lineItems && + autoCollection == other.autoCollection && customerId == other.customerId && discount == other.discount && dueDate == other.dueDate && @@ -1393,6 +1499,7 @@ private constructor( currency, invoiceDate, lineItems, + autoCollection, customerId, discount, dueDate, @@ -1408,7 +1515,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{currency=$currency, invoiceDate=$invoiceDate, lineItems=$lineItems, customerId=$customerId, discount=$discount, dueDate=$dueDate, externalCustomerId=$externalCustomerId, memo=$memo, metadata=$metadata, netTerms=$netTerms, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" + "Body{currency=$currency, invoiceDate=$invoiceDate, lineItems=$lineItems, autoCollection=$autoCollection, customerId=$customerId, discount=$discount, dueDate=$dueDate, externalCustomerId=$externalCustomerId, memo=$memo, metadata=$metadata, netTerms=$netTerms, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" } class LineItem diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index c57bd6e61..80db7641e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -396,6 +396,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -443,6 +444,11 @@ private constructor( /** * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the * first discount in the list will be returned. If the list is empty, `None` will be returned. + * + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = invoiceFetchUpcomingResponse.discount().convert(MyClass.class); + * ``` */ @Deprecated("deprecated") @JsonProperty("discount") @@ -1440,6 +1446,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt new file mode 100644 index 000000000..afb1253db --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt @@ -0,0 +1,443 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint allows an eligible invoice to be issued manually. This is only possible with + * invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` is a + * time in the past. Issuing an invoice could possibly trigger side effects, some of which could be + * customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice to external + * providers, etc). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice summary + * without any line item details. + */ +class InvoiceIssueSummaryParams +private constructor( + private val invoiceId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun invoiceId(): Optional = Optional.ofNullable(invoiceId) + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have no usage + * fees. If the invoice is configured to sync to an external provider, a successful response + * from this endpoint guarantees the invoice is present in the provider. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun synchronous(): Optional = body.synchronous() + + /** + * Returns the raw JSON value of [synchronous]. + * + * Unlike [synchronous], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _synchronous(): JsonField = body._synchronous() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InvoiceIssueSummaryParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [InvoiceIssueSummaryParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvoiceIssueSummaryParams]. */ + class Builder internal constructor() { + + private var invoiceId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(invoiceIssueSummaryParams: InvoiceIssueSummaryParams) = apply { + invoiceId = invoiceIssueSummaryParams.invoiceId + body = invoiceIssueSummaryParams.body.toBuilder() + additionalHeaders = invoiceIssueSummaryParams.additionalHeaders.toBuilder() + additionalQueryParams = invoiceIssueSummaryParams.additionalQueryParams.toBuilder() + } + + fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + + /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [synchronous] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have no usage + * fees. If the invoice is configured to sync to an external provider, a successful response + * from this endpoint guarantees the invoice is present in the provider. + */ + fun synchronous(synchronous: Boolean) = apply { body.synchronous(synchronous) } + + /** + * Sets [Builder.synchronous] to an arbitrary JSON value. + * + * You should usually call [Builder.synchronous] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun synchronous(synchronous: JsonField) = apply { body.synchronous(synchronous) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InvoiceIssueSummaryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvoiceIssueSummaryParams = + InvoiceIssueSummaryParams( + invoiceId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> invoiceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val synchronous: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("synchronous") + @ExcludeMissing + synchronous: JsonField = JsonMissing.of() + ) : this(synchronous, mutableMapOf()) + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have no usage + * fees. If the invoice is configured to sync to an external provider, a successful response + * from this endpoint guarantees the invoice is present in the provider. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun synchronous(): Optional = synchronous.getOptional("synchronous") + + /** + * Returns the raw JSON value of [synchronous]. + * + * Unlike [synchronous], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("synchronous") + @ExcludeMissing + fun _synchronous(): JsonField = synchronous + + @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 [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var synchronous: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + synchronous = body.synchronous + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be + * issued asynchronously. The synchronous option is only available for invoices that + * have no usage fees. If the invoice is configured to sync to an external provider, a + * successful response from this endpoint guarantees the invoice is present in the + * provider. + */ + fun synchronous(synchronous: Boolean) = synchronous(JsonField.of(synchronous)) + + /** + * Sets [Builder.synchronous] to an arbitrary JSON value. + * + * You should usually call [Builder.synchronous] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun synchronous(synchronous: JsonField) = apply { + this.synchronous = synchronous + } + + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(synchronous, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + synchronous() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (synchronous.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + synchronous == other.synchronous && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(synchronous, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{synchronous=$synchronous, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceIssueSummaryParams && + invoiceId == other.invoiceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InvoiceIssueSummaryParams{invoiceId=$invoiceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt new file mode 100644 index 000000000..8d14fcce3 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt @@ -0,0 +1,4593 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** #InvoiceApiResourceWithoutLineItems */ +class InvoiceIssueSummaryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val amountDue: JsonField, + private val autoCollection: JsonField, + private val billingAddress: JsonField
, + private val createdAt: JsonField, + private val creditNotes: JsonField>, + private val currency: JsonField, + private val customer: JsonField, + private val customerBalanceTransactions: JsonField>, + private val customerTaxId: JsonField, + private val dueDate: JsonField, + private val eligibleToIssueAt: JsonField, + private val hostedInvoiceUrl: JsonField, + private val invoiceDate: JsonField, + private val invoiceNumber: JsonField, + private val invoicePdf: JsonField, + private val invoiceSource: JsonField, + private val issueFailedAt: JsonField, + private val issuedAt: JsonField, + private val memo: JsonField, + private val metadata: JsonField, + private val paidAt: JsonField, + private val paymentAttempts: JsonField>, + private val paymentFailedAt: JsonField, + private val paymentStartedAt: JsonField, + private val scheduledIssueAt: JsonField, + private val shippingAddress: JsonField
, + private val status: JsonField, + private val subscription: JsonField, + private val syncFailedAt: JsonField, + private val total: JsonField, + private val voidedAt: JsonField, + private val willAutoIssue: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount_due") @ExcludeMissing amountDue: JsonField = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + billingAddress: JsonField
= JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_notes") + @ExcludeMissing + creditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + customerBalanceTransactions: JsonField> = JsonMissing.of(), + @JsonProperty("customer_tax_id") + @ExcludeMissing + customerTaxId: JsonField = JsonMissing.of(), + @JsonProperty("due_date") + @ExcludeMissing + dueDate: JsonField = JsonMissing.of(), + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + eligibleToIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + hostedInvoiceUrl: JsonField = JsonMissing.of(), + @JsonProperty("invoice_date") + @ExcludeMissing + invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_number") + @ExcludeMissing + invoiceNumber: JsonField = JsonMissing.of(), + @JsonProperty("invoice_pdf") + @ExcludeMissing + invoicePdf: JsonField = JsonMissing.of(), + @JsonProperty("invoice_source") + @ExcludeMissing + invoiceSource: JsonField = JsonMissing.of(), + @JsonProperty("issue_failed_at") + @ExcludeMissing + issueFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("issued_at") + @ExcludeMissing + issuedAt: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("paid_at") + @ExcludeMissing + paidAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_attempts") + @ExcludeMissing + paymentAttempts: JsonField> = JsonMissing.of(), + @JsonProperty("payment_failed_at") + @ExcludeMissing + paymentFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_started_at") + @ExcludeMissing + paymentStartedAt: JsonField = JsonMissing.of(), + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + scheduledIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + shippingAddress: JsonField
= JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + @JsonProperty("sync_failed_at") + @ExcludeMissing + syncFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + @JsonProperty("will_auto_issue") + @ExcludeMissing + willAutoIssue: JsonField = JsonMissing.of(), + ) : this( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + issueFailedAt, + issuedAt, + memo, + metadata, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * This is the final amount required to be charged to the customer and reflects the application + * of the customer balance to the `total` of the invoice. + * + * @throws OrbInvalidDataException 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 amountDue(): String = amountDue.getRequired("amount_due") + + /** + * @throws OrbInvalidDataException 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 autoCollection(): AutoCollection = autoCollection.getRequired("auto_collection") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingAddress(): Optional
= billingAddress.getOptional("billing_address") + + /** + * The creation time of the resource in Orb. + * + * @throws OrbInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * A list of credit notes associated with the invoice + * + * @throws OrbInvalidDataException 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 creditNotes(): List = creditNotes.getRequired("credit_notes") + + /** + * An ISO 4217 currency string or `credits` + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException 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 customer(): CustomerMinified = customer.getRequired("customer") + + /** + * @throws OrbInvalidDataException 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 customerBalanceTransactions(): List = + customerBalanceTransactions.getRequired("customer_balance_transactions") + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to the + * headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |----------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Albania |`al_tin` |Albania Tax Identification Number | + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Angola |`ao_tin` |Angola Tax Identification Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Armenia |`am_tin` |Armenia Tax Identification Number | + * |Aruba |`aw_tin` |Aruba Tax Identification Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Azerbaijan |`az_tin` |Azerbaijan Tax Identification Number | + * |Bahamas |`bs_tin` |Bahamas Tax Identification Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Bangladesh |`bd_bin` |Bangladesh Business Identification Number | + * |Barbados |`bb_tin` |Barbados Tax Identification Number | + * |Belarus |`by_tin` |Belarus TIN Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Benin |`bj_ifu` |Benin Tax Identification Number (Identifiant Fiscal Unique) | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Bosnia and Herzegovina|`ba_tin` |Bosnia and Herzegovina Tax Identification Number | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Burkina Faso |`bf_ifu` |Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * |Cambodia |`kh_tin` |Cambodia Tax Identification Number | + * |Cameroon |`cm_niu` |Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (Québec) | + * |Cape Verde |`cv_nif` |Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Congo-Kinshasa |`cd_nif` |Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Croatia |`hr_oib` |Croatian Personal Identification Number (OIB) | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | + * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`de_stn` |German Tax Number (Steuernummer) | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | + * |Laos |`la_tin` |Laos Tax Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Liechtenstein |`li_vat` |Liechtenstein VAT Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat` |European VAT Number | + * |Mauritania |`mr_nif` |Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Moldova |`md_vat` |Moldova VAT Number | + * |Montenegro |`me_pib` |Montenegro PIB Number | + * |Morocco |`ma_vat` |Morocco VAT Number | + * |Nepal |`np_pan` |Nepal PAN Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |North Macedonia |`mk_vat` |North Macedonia VAT Number | + * |Northern Ireland |`eu_vat` |Northern Ireland VAT Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Senegal |`sn_ninea` |Senegal NINEA Number | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna številka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Suriname |`sr_fin` |Suriname FIN Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_uid` |Switzerland UID Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Tajikistan |`tj_tin` |Tajikistan Tax Identification Number | + * |Tanzania |`tz_vat` |Tanzania VAT Number | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Uganda |`ug_tin` |Uganda Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates |`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Uzbekistan |`uz_tin` |Uzbekistan TIN Number | + * |Uzbekistan |`uz_vat` |Uzbekistan VAT Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * |Zambia |`zm_tin` |Zambia Tax Identification Number | + * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun customerTaxId(): Optional = customerTaxId.getOptional("customer_tax_id") + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet finalized. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun dueDate(): Optional = dueDate.getOptional("due_date") + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will be + * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice will + * automatically begin issuing at this time. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun eligibleToIssueAt(): Optional = + eligibleToIssueAt.getOptional("eligible_to_issue_at") + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the invoice's + * due date, or 60 days after being re-generated through the UI. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun hostedInvoiceUrl(): Optional = hostedInvoiceUrl.getOptional("hosted_invoice_url") + + /** + * The scheduled date of the invoice + * + * @throws OrbInvalidDataException 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 invoiceDate(): OffsetDateTime = invoiceDate.getRequired("invoice_date") + + /** + * Automatically generated invoice number to help track and reconcile invoices. Invoice numbers + * have a prefix such as `RFOBWG`. These can be sequential per account or customer. + * + * @throws OrbInvalidDataException 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 invoiceNumber(): String = invoiceNumber.getRequired("invoice_number") + + /** + * The link to download the PDF representation of the `Invoice`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoicePdf(): Optional = invoicePdf.getOptional("invoice_pdf") + + /** + * @throws OrbInvalidDataException 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 invoiceSource(): InvoiceSource = invoiceSource.getRequired("invoice_source") + + /** + * If the invoice failed to issue, this will be the last time it failed to issue (even if it is + * now in a different state.) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun issueFailedAt(): Optional = issueFailedAt.getOptional("issue_failed_at") + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even if it + * is now in a different state.) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun issuedAt(): Optional = issuedAt.getOptional("issued_at") + + /** + * Free-form text which is available on the invoice PDF and the Orb invoice portal. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun memo(): Optional = memo.getOptional("memo") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException 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 metadata(): Metadata = metadata.getRequired("metadata") + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paidAt(): Optional = paidAt.getOptional("paid_at") + + /** + * A list of payment attempts associated with the invoice + * + * @throws OrbInvalidDataException 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 paymentAttempts(): List = paymentAttempts.getRequired("payment_attempts") + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most recent + * attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentFailedAt(): Optional = + paymentFailedAt.getOptional("payment_failed_at") + + /** + * If payment was attempted on this invoice, this will be the start time of the most recent + * attempt. This field is especially useful for delayed-notification payment mechanisms (like + * bank transfers), where payment can take 3 days or more. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentStartedAt(): Optional = + paymentStartedAt.getOptional("payment_started_at") + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be + * issued. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun scheduledIssueAt(): Optional = + scheduledIssueAt.getOptional("scheduled_issue_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun shippingAddress(): Optional
= shippingAddress.getOptional("shipping_address") + + /** + * @throws OrbInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun subscription(): Optional = subscription.getOptional("subscription") + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider sync + * was attempted. This field will always be `null` for invoices using Orb Invoicing. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun syncFailedAt(): Optional = syncFailedAt.getOptional("sync_failed_at") + + /** + * The total after any minimums and discounts have been applied. + * + * @throws OrbInvalidDataException 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 total(): String = total.getRequired("total") + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was voided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun voidedAt(): Optional = voidedAt.getOptional("voided_at") + + /** + * This is true if the invoice will be automatically issued in the future, and false otherwise. + * + * @throws OrbInvalidDataException 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 willAutoIssue(): Boolean = willAutoIssue.getRequired("will_auto_issue") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [amountDue]. + * + * Unlike [amountDue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue + + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * Returns the raw JSON value of [billingAddress]. + * + * Unlike [billingAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField
= billingAddress + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditNotes]. + * + * Unlike [creditNotes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_notes") + @ExcludeMissing + fun _creditNotes(): JsonField> = creditNotes + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [customerBalanceTransactions]. + * + * Unlike [customerBalanceTransactions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + fun _customerBalanceTransactions(): JsonField> = + customerBalanceTransactions + + /** + * Returns the raw JSON value of [customerTaxId]. + * + * Unlike [customerTaxId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_tax_id") + @ExcludeMissing + fun _customerTaxId(): JsonField = customerTaxId + + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate + + /** + * Returns the raw JSON value of [eligibleToIssueAt]. + * + * Unlike [eligibleToIssueAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + fun _eligibleToIssueAt(): JsonField = eligibleToIssueAt + + /** + * Returns the raw JSON value of [hostedInvoiceUrl]. + * + * Unlike [hostedInvoiceUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + fun _hostedInvoiceUrl(): JsonField = hostedInvoiceUrl + + /** + * Returns the raw JSON value of [invoiceDate]. + * + * Unlike [invoiceDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = invoiceDate + + /** + * Returns the raw JSON value of [invoiceNumber]. + * + * Unlike [invoiceNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber + + /** + * Returns the raw JSON value of [invoicePdf]. + * + * Unlike [invoicePdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_pdf") @ExcludeMissing fun _invoicePdf(): JsonField = invoicePdf + + /** + * Returns the raw JSON value of [invoiceSource]. + * + * Unlike [invoiceSource], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_source") + @ExcludeMissing + fun _invoiceSource(): JsonField = invoiceSource + + /** + * Returns the raw JSON value of [issueFailedAt]. + * + * Unlike [issueFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issue_failed_at") + @ExcludeMissing + fun _issueFailedAt(): JsonField = issueFailedAt + + /** + * Returns the raw JSON value of [issuedAt]. + * + * Unlike [issuedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issued_at") @ExcludeMissing fun _issuedAt(): JsonField = issuedAt + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [paidAt]. + * + * Unlike [paidAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paid_at") @ExcludeMissing fun _paidAt(): JsonField = paidAt + + /** + * Returns the raw JSON value of [paymentAttempts]. + * + * Unlike [paymentAttempts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_attempts") + @ExcludeMissing + fun _paymentAttempts(): JsonField> = paymentAttempts + + /** + * Returns the raw JSON value of [paymentFailedAt]. + * + * Unlike [paymentFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_failed_at") + @ExcludeMissing + fun _paymentFailedAt(): JsonField = paymentFailedAt + + /** + * Returns the raw JSON value of [paymentStartedAt]. + * + * Unlike [paymentStartedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_started_at") + @ExcludeMissing + fun _paymentStartedAt(): JsonField = paymentStartedAt + + /** + * Returns the raw JSON value of [scheduledIssueAt]. + * + * Unlike [scheduledIssueAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + fun _scheduledIssueAt(): JsonField = scheduledIssueAt + + /** + * Returns the raw JSON value of [shippingAddress]. + * + * Unlike [shippingAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField
= shippingAddress + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** + * Returns the raw JSON value of [syncFailedAt]. + * + * Unlike [syncFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sync_failed_at") + @ExcludeMissing + fun _syncFailedAt(): JsonField = syncFailedAt + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * Returns the raw JSON value of [voidedAt]. + * + * Unlike [voidedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt + + /** + * Returns the raw JSON value of [willAutoIssue]. + * + * Unlike [willAutoIssue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("will_auto_issue") + @ExcludeMissing + fun _willAutoIssue(): JsonField = willAutoIssue + + @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 [InvoiceIssueSummaryResponse]. + * + * The following fields are required: + * ```java + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .memo() + * .metadata() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvoiceIssueSummaryResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amountDue: JsonField? = null + private var autoCollection: JsonField? = null + private var billingAddress: JsonField
? = null + private var createdAt: JsonField? = null + private var creditNotes: JsonField>? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var customerBalanceTransactions: + JsonField>? = + null + private var customerTaxId: JsonField? = null + private var dueDate: JsonField? = null + private var eligibleToIssueAt: JsonField? = null + private var hostedInvoiceUrl: JsonField? = null + private var invoiceDate: JsonField? = null + private var invoiceNumber: JsonField? = null + private var invoicePdf: JsonField? = null + private var invoiceSource: JsonField? = null + private var issueFailedAt: JsonField? = null + private var issuedAt: JsonField? = null + private var memo: JsonField? = null + private var metadata: JsonField? = null + private var paidAt: JsonField? = null + private var paymentAttempts: JsonField>? = null + private var paymentFailedAt: JsonField? = null + private var paymentStartedAt: JsonField? = null + private var scheduledIssueAt: JsonField? = null + private var shippingAddress: JsonField
? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var syncFailedAt: JsonField? = null + private var total: JsonField? = null + private var voidedAt: JsonField? = null + private var willAutoIssue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoiceIssueSummaryResponse: InvoiceIssueSummaryResponse) = apply { + id = invoiceIssueSummaryResponse.id + amountDue = invoiceIssueSummaryResponse.amountDue + autoCollection = invoiceIssueSummaryResponse.autoCollection + billingAddress = invoiceIssueSummaryResponse.billingAddress + createdAt = invoiceIssueSummaryResponse.createdAt + creditNotes = invoiceIssueSummaryResponse.creditNotes.map { it.toMutableList() } + currency = invoiceIssueSummaryResponse.currency + customer = invoiceIssueSummaryResponse.customer + customerBalanceTransactions = + invoiceIssueSummaryResponse.customerBalanceTransactions.map { it.toMutableList() } + customerTaxId = invoiceIssueSummaryResponse.customerTaxId + dueDate = invoiceIssueSummaryResponse.dueDate + eligibleToIssueAt = invoiceIssueSummaryResponse.eligibleToIssueAt + hostedInvoiceUrl = invoiceIssueSummaryResponse.hostedInvoiceUrl + invoiceDate = invoiceIssueSummaryResponse.invoiceDate + invoiceNumber = invoiceIssueSummaryResponse.invoiceNumber + invoicePdf = invoiceIssueSummaryResponse.invoicePdf + invoiceSource = invoiceIssueSummaryResponse.invoiceSource + issueFailedAt = invoiceIssueSummaryResponse.issueFailedAt + issuedAt = invoiceIssueSummaryResponse.issuedAt + memo = invoiceIssueSummaryResponse.memo + metadata = invoiceIssueSummaryResponse.metadata + paidAt = invoiceIssueSummaryResponse.paidAt + paymentAttempts = invoiceIssueSummaryResponse.paymentAttempts.map { it.toMutableList() } + paymentFailedAt = invoiceIssueSummaryResponse.paymentFailedAt + paymentStartedAt = invoiceIssueSummaryResponse.paymentStartedAt + scheduledIssueAt = invoiceIssueSummaryResponse.scheduledIssueAt + shippingAddress = invoiceIssueSummaryResponse.shippingAddress + status = invoiceIssueSummaryResponse.status + subscription = invoiceIssueSummaryResponse.subscription + syncFailedAt = invoiceIssueSummaryResponse.syncFailedAt + total = invoiceIssueSummaryResponse.total + voidedAt = invoiceIssueSummaryResponse.voidedAt + willAutoIssue = invoiceIssueSummaryResponse.willAutoIssue + additionalProperties = invoiceIssueSummaryResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * This is the final amount required to be charged to the customer and reflects the + * application of the customer balance to the `total` of the invoice. + */ + fun amountDue(amountDue: String) = amountDue(JsonField.of(amountDue)) + + /** + * Sets [Builder.amountDue] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDue] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } + + fun autoCollection(autoCollection: AutoCollection) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [AutoCollection] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingAddress(billingAddress: Address?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + /** Alias for calling [Builder.billingAddress] with `billingAddress.orElse(null)`. */ + fun billingAddress(billingAddress: Optional
) = + billingAddress(billingAddress.getOrNull()) + + /** + * Sets [Builder.billingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.billingAddress] with a well-typed [Address] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingAddress(billingAddress: JsonField
) = apply { + this.billingAddress = billingAddress + } + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** A list of credit notes associated with the invoice */ + fun creditNotes(creditNotes: List) = creditNotes(JsonField.of(creditNotes)) + + /** + * Sets [Builder.creditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNotes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNotes(creditNotes: JsonField>) = apply { + this.creditNotes = creditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [creditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreditNote(creditNote: CreditNote) = apply { + creditNotes = + (creditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("creditNotes", it).add(creditNote) + } + } + + /** An ISO 4217 currency string or `credits` */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun customer(customer: CustomerMinified) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [CustomerMinified] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + fun customerBalanceTransactions( + customerBalanceTransactions: List + ) = customerBalanceTransactions(JsonField.of(customerBalanceTransactions)) + + /** + * Sets [Builder.customerBalanceTransactions] to an arbitrary JSON value. + * + * You should usually call [Builder.customerBalanceTransactions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun customerBalanceTransactions( + customerBalanceTransactions: JsonField> + ) = apply { + this.customerBalanceTransactions = + customerBalanceTransactions.map { it.toMutableList() } + } + + /** + * Adds a single [CustomerBalanceTransaction] to [customerBalanceTransactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomerBalanceTransaction(customerBalanceTransaction: CustomerBalanceTransaction) = + apply { + customerBalanceTransactions = + (customerBalanceTransactions ?: JsonField.of(mutableListOf())).also { + checkKnown("customerBalanceTransactions", it) + .add(customerBalanceTransaction) + } + } + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |----------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Albania |`al_tin` |Albania Tax Identification Number | + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Angola |`ao_tin` |Angola Tax Identification Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Armenia |`am_tin` |Armenia Tax Identification Number | + * |Aruba |`aw_tin` |Aruba Tax Identification Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Azerbaijan |`az_tin` |Azerbaijan Tax Identification Number | + * |Bahamas |`bs_tin` |Bahamas Tax Identification Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Bangladesh |`bd_bin` |Bangladesh Business Identification Number | + * |Barbados |`bb_tin` |Barbados Tax Identification Number | + * |Belarus |`by_tin` |Belarus TIN Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Benin |`bj_ifu` |Benin Tax Identification Number (Identifiant Fiscal Unique) | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Bosnia and Herzegovina|`ba_tin` |Bosnia and Herzegovina Tax Identification Number | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Burkina Faso |`bf_ifu` |Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * |Cambodia |`kh_tin` |Cambodia Tax Identification Number | + * |Cameroon |`cm_niu` |Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (Québec) | + * |Cape Verde |`cv_nif` |Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Congo-Kinshasa |`cd_nif` |Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Croatia |`hr_oib` |Croatian Personal Identification Number (OIB) | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | + * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`de_stn` |German Tax Number (Steuernummer) | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | + * |Laos |`la_tin` |Laos Tax Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Liechtenstein |`li_vat` |Liechtenstein VAT Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat` |European VAT Number | + * |Mauritania |`mr_nif` |Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Moldova |`md_vat` |Moldova VAT Number | + * |Montenegro |`me_pib` |Montenegro PIB Number | + * |Morocco |`ma_vat` |Morocco VAT Number | + * |Nepal |`np_pan` |Nepal PAN Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |North Macedonia |`mk_vat` |North Macedonia VAT Number | + * |Northern Ireland |`eu_vat` |Northern Ireland VAT Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Senegal |`sn_ninea` |Senegal NINEA Number | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna številka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Suriname |`sr_fin` |Suriname FIN Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_uid` |Switzerland UID Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Tajikistan |`tj_tin` |Tajikistan Tax Identification Number | + * |Tanzania |`tz_vat` |Tanzania VAT Number | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Uganda |`ug_tin` |Uganda Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates |`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Uzbekistan |`uz_tin` |Uzbekistan TIN Number | + * |Uzbekistan |`uz_vat` |Uzbekistan VAT Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * |Zambia |`zm_tin` |Zambia Tax Identification Number | + * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | + */ + fun customerTaxId(customerTaxId: CustomerTaxId?) = + customerTaxId(JsonField.ofNullable(customerTaxId)) + + /** Alias for calling [Builder.customerTaxId] with `customerTaxId.orElse(null)`. */ + fun customerTaxId(customerTaxId: Optional) = + customerTaxId(customerTaxId.getOrNull()) + + /** + * Sets [Builder.customerTaxId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerTaxId] with a well-typed [CustomerTaxId] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerTaxId(customerTaxId: JsonField) = apply { + this.customerTaxId = customerTaxId + } + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. + */ + fun dueDate(dueDate: OffsetDateTime?) = dueDate(JsonField.ofNullable(dueDate)) + + /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.getOrNull()) + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will be + * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice + * will automatically begin issuing at this time. + */ + fun eligibleToIssueAt(eligibleToIssueAt: OffsetDateTime?) = + eligibleToIssueAt(JsonField.ofNullable(eligibleToIssueAt)) + + /** Alias for calling [Builder.eligibleToIssueAt] with `eligibleToIssueAt.orElse(null)`. */ + fun eligibleToIssueAt(eligibleToIssueAt: Optional) = + eligibleToIssueAt(eligibleToIssueAt.getOrNull()) + + /** + * Sets [Builder.eligibleToIssueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.eligibleToIssueAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun eligibleToIssueAt(eligibleToIssueAt: JsonField) = apply { + this.eligibleToIssueAt = eligibleToIssueAt + } + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the + * invoice's due date, or 60 days after being re-generated through the UI. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: String?) = + hostedInvoiceUrl(JsonField.ofNullable(hostedInvoiceUrl)) + + /** Alias for calling [Builder.hostedInvoiceUrl] with `hostedInvoiceUrl.orElse(null)`. */ + fun hostedInvoiceUrl(hostedInvoiceUrl: Optional) = + hostedInvoiceUrl(hostedInvoiceUrl.getOrNull()) + + /** + * Sets [Builder.hostedInvoiceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.hostedInvoiceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: JsonField) = apply { + this.hostedInvoiceUrl = hostedInvoiceUrl + } + + /** The scheduled date of the invoice */ + fun invoiceDate(invoiceDate: OffsetDateTime) = invoiceDate(JsonField.of(invoiceDate)) + + /** + * Sets [Builder.invoiceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + this.invoiceDate = invoiceDate + } + + /** + * Automatically generated invoice number to help track and reconcile invoices. Invoice + * numbers have a prefix such as `RFOBWG`. These can be sequential per account or customer. + */ + fun invoiceNumber(invoiceNumber: String) = invoiceNumber(JsonField.of(invoiceNumber)) + + /** + * Sets [Builder.invoiceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoiceNumber(invoiceNumber: JsonField) = apply { + this.invoiceNumber = invoiceNumber + } + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: String?) = invoicePdf(JsonField.ofNullable(invoicePdf)) + + /** Alias for calling [Builder.invoicePdf] with `invoicePdf.orElse(null)`. */ + fun invoicePdf(invoicePdf: Optional) = invoicePdf(invoicePdf.getOrNull()) + + /** + * Sets [Builder.invoicePdf] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicePdf] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicePdf(invoicePdf: JsonField) = apply { this.invoicePdf = invoicePdf } + + fun invoiceSource(invoiceSource: InvoiceSource) = invoiceSource(JsonField.of(invoiceSource)) + + /** + * Sets [Builder.invoiceSource] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceSource] with a well-typed [InvoiceSource] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceSource(invoiceSource: JsonField) = apply { + this.invoiceSource = invoiceSource + } + + /** + * If the invoice failed to issue, this will be the last time it failed to issue (even if it + * is now in a different state.) + */ + fun issueFailedAt(issueFailedAt: OffsetDateTime?) = + issueFailedAt(JsonField.ofNullable(issueFailedAt)) + + /** Alias for calling [Builder.issueFailedAt] with `issueFailedAt.orElse(null)`. */ + fun issueFailedAt(issueFailedAt: Optional) = + issueFailedAt(issueFailedAt.getOrNull()) + + /** + * Sets [Builder.issueFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issueFailedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issueFailedAt(issueFailedAt: JsonField) = apply { + this.issueFailedAt = issueFailedAt + } + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even + * if it is now in a different state.) + */ + fun issuedAt(issuedAt: OffsetDateTime?) = issuedAt(JsonField.ofNullable(issuedAt)) + + /** Alias for calling [Builder.issuedAt] with `issuedAt.orElse(null)`. */ + fun issuedAt(issuedAt: Optional) = issuedAt(issuedAt.getOrNull()) + + /** + * Sets [Builder.issuedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuedAt(issuedAt: JsonField) = apply { this.issuedAt = issuedAt } + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** Alias for calling [Builder.memo] with `memo.orElse(null)`. */ + fun memo(memo: Optional) = memo(memo.getOrNull()) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * You should usually call [Builder.memo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + */ + fun paidAt(paidAt: OffsetDateTime?) = paidAt(JsonField.ofNullable(paidAt)) + + /** Alias for calling [Builder.paidAt] with `paidAt.orElse(null)`. */ + fun paidAt(paidAt: Optional) = paidAt(paidAt.getOrNull()) + + /** + * Sets [Builder.paidAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paidAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paidAt(paidAt: JsonField) = apply { this.paidAt = paidAt } + + /** A list of payment attempts associated with the invoice */ + fun paymentAttempts(paymentAttempts: List) = + paymentAttempts(JsonField.of(paymentAttempts)) + + /** + * Sets [Builder.paymentAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAttempts] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun paymentAttempts(paymentAttempts: JsonField>) = apply { + this.paymentAttempts = paymentAttempts.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentAttempt] to [paymentAttempts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentAttempt(paymentAttempt: PaymentAttempt) = apply { + paymentAttempts = + (paymentAttempts ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentAttempts", it).add(paymentAttempt) + } + } + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most + * recent attempt. + */ + fun paymentFailedAt(paymentFailedAt: OffsetDateTime?) = + paymentFailedAt(JsonField.ofNullable(paymentFailedAt)) + + /** Alias for calling [Builder.paymentFailedAt] with `paymentFailedAt.orElse(null)`. */ + fun paymentFailedAt(paymentFailedAt: Optional) = + paymentFailedAt(paymentFailedAt.getOrNull()) + + /** + * Sets [Builder.paymentFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentFailedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun paymentFailedAt(paymentFailedAt: JsonField) = apply { + this.paymentFailedAt = paymentFailedAt + } + + /** + * If payment was attempted on this invoice, this will be the start time of the most recent + * attempt. This field is especially useful for delayed-notification payment mechanisms + * (like bank transfers), where payment can take 3 days or more. + */ + fun paymentStartedAt(paymentStartedAt: OffsetDateTime?) = + paymentStartedAt(JsonField.ofNullable(paymentStartedAt)) + + /** Alias for calling [Builder.paymentStartedAt] with `paymentStartedAt.orElse(null)`. */ + fun paymentStartedAt(paymentStartedAt: Optional) = + paymentStartedAt(paymentStartedAt.getOrNull()) + + /** + * Sets [Builder.paymentStartedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentStartedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun paymentStartedAt(paymentStartedAt: JsonField) = apply { + this.paymentStartedAt = paymentStartedAt + } + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to + * be issued. + */ + fun scheduledIssueAt(scheduledIssueAt: OffsetDateTime?) = + scheduledIssueAt(JsonField.ofNullable(scheduledIssueAt)) + + /** Alias for calling [Builder.scheduledIssueAt] with `scheduledIssueAt.orElse(null)`. */ + fun scheduledIssueAt(scheduledIssueAt: Optional) = + scheduledIssueAt(scheduledIssueAt.getOrNull()) + + /** + * Sets [Builder.scheduledIssueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledIssueAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scheduledIssueAt(scheduledIssueAt: JsonField) = apply { + this.scheduledIssueAt = scheduledIssueAt + } + + fun shippingAddress(shippingAddress: Address?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + /** Alias for calling [Builder.shippingAddress] with `shippingAddress.orElse(null)`. */ + fun shippingAddress(shippingAddress: Optional
) = + shippingAddress(shippingAddress.getOrNull()) + + /** + * Sets [Builder.shippingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingAddress] with a well-typed [Address] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shippingAddress(shippingAddress: JsonField
) = apply { + this.shippingAddress = shippingAddress + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: SubscriptionMinified?) = + subscription(JsonField.ofNullable(subscription)) + + /** Alias for calling [Builder.subscription] with `subscription.orElse(null)`. */ + fun subscription(subscription: Optional) = + subscription(subscription.getOrNull()) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed [SubscriptionMinified] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider + * sync was attempted. This field will always be `null` for invoices using Orb Invoicing. + */ + fun syncFailedAt(syncFailedAt: OffsetDateTime?) = + syncFailedAt(JsonField.ofNullable(syncFailedAt)) + + /** Alias for calling [Builder.syncFailedAt] with `syncFailedAt.orElse(null)`. */ + fun syncFailedAt(syncFailedAt: Optional) = + syncFailedAt(syncFailedAt.getOrNull()) + + /** + * Sets [Builder.syncFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.syncFailedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun syncFailedAt(syncFailedAt: JsonField) = apply { + this.syncFailedAt = syncFailedAt + } + + /** The total after any minimums and discounts have been applied. */ + fun total(total: String) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + */ + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** Alias for calling [Builder.voidedAt] with `voidedAt.orElse(null)`. */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.getOrNull()) + + /** + * Sets [Builder.voidedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } + + /** + * This is true if the invoice will be automatically issued in the future, and false + * otherwise. + */ + fun willAutoIssue(willAutoIssue: Boolean) = willAutoIssue(JsonField.of(willAutoIssue)) + + /** + * Sets [Builder.willAutoIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.willAutoIssue] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun willAutoIssue(willAutoIssue: JsonField) = apply { + this.willAutoIssue = willAutoIssue + } + + 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 [InvoiceIssueSummaryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .memo() + * .metadata() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse( + checkRequired("id", id), + checkRequired("amountDue", amountDue), + checkRequired("autoCollection", autoCollection), + checkRequired("billingAddress", billingAddress), + checkRequired("createdAt", createdAt), + checkRequired("creditNotes", creditNotes).map { it.toImmutable() }, + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("customerBalanceTransactions", customerBalanceTransactions).map { + it.toImmutable() + }, + checkRequired("customerTaxId", customerTaxId), + checkRequired("dueDate", dueDate), + checkRequired("eligibleToIssueAt", eligibleToIssueAt), + checkRequired("hostedInvoiceUrl", hostedInvoiceUrl), + checkRequired("invoiceDate", invoiceDate), + checkRequired("invoiceNumber", invoiceNumber), + checkRequired("invoicePdf", invoicePdf), + checkRequired("invoiceSource", invoiceSource), + checkRequired("issueFailedAt", issueFailedAt), + checkRequired("issuedAt", issuedAt), + checkRequired("memo", memo), + checkRequired("metadata", metadata), + checkRequired("paidAt", paidAt), + checkRequired("paymentAttempts", paymentAttempts).map { it.toImmutable() }, + checkRequired("paymentFailedAt", paymentFailedAt), + checkRequired("paymentStartedAt", paymentStartedAt), + checkRequired("scheduledIssueAt", scheduledIssueAt), + checkRequired("shippingAddress", shippingAddress), + checkRequired("status", status), + checkRequired("subscription", subscription), + checkRequired("syncFailedAt", syncFailedAt), + checkRequired("total", total), + checkRequired("voidedAt", voidedAt), + checkRequired("willAutoIssue", willAutoIssue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvoiceIssueSummaryResponse = apply { + if (validated) { + return@apply + } + + id() + amountDue() + autoCollection().validate() + billingAddress().ifPresent { it.validate() } + createdAt() + creditNotes().forEach { it.validate() } + currency() + customer().validate() + customerBalanceTransactions().forEach { it.validate() } + customerTaxId().ifPresent { it.validate() } + dueDate() + eligibleToIssueAt() + hostedInvoiceUrl() + invoiceDate() + invoiceNumber() + invoicePdf() + invoiceSource().validate() + issueFailedAt() + issuedAt() + memo() + metadata().validate() + paidAt() + paymentAttempts().forEach { it.validate() } + paymentFailedAt() + paymentStartedAt() + scheduledIssueAt() + shippingAddress().ifPresent { it.validate() } + status().validate() + subscription().ifPresent { it.validate() } + syncFailedAt() + total() + voidedAt() + willAutoIssue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (amountDue.asKnown().isPresent) 1 else 0) + + (autoCollection.asKnown().getOrNull()?.validity() ?: 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (customerBalanceTransactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (customerTaxId.asKnown().getOrNull()?.validity() ?: 0) + + (if (dueDate.asKnown().isPresent) 1 else 0) + + (if (eligibleToIssueAt.asKnown().isPresent) 1 else 0) + + (if (hostedInvoiceUrl.asKnown().isPresent) 1 else 0) + + (if (invoiceDate.asKnown().isPresent) 1 else 0) + + (if (invoiceNumber.asKnown().isPresent) 1 else 0) + + (if (invoicePdf.asKnown().isPresent) 1 else 0) + + (invoiceSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (issueFailedAt.asKnown().isPresent) 1 else 0) + + (if (issuedAt.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (paidAt.asKnown().isPresent) 1 else 0) + + (paymentAttempts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (paymentFailedAt.asKnown().isPresent) 1 else 0) + + (if (paymentStartedAt.asKnown().isPresent) 1 else 0) + + (if (scheduledIssueAt.asKnown().isPresent) 1 else 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (if (syncFailedAt.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + (if (willAutoIssue.asKnown().isPresent) 1 else 0) + + class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabled: JsonField, + private val nextAttemptAt: JsonField, + private val numAttempts: JsonField, + private val previouslyAttemptedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("next_attempt_at") + @ExcludeMissing + nextAttemptAt: JsonField = JsonMissing.of(), + @JsonProperty("num_attempts") + @ExcludeMissing + numAttempts: JsonField = JsonMissing.of(), + @JsonProperty("previously_attempted_at") + @ExcludeMissing + previouslyAttemptedAt: JsonField = JsonMissing.of(), + ) : this(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, mutableMapOf()) + + /** + * True only if auto-collection is enabled for this invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Optional = enabled.getOptional("enabled") + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the next + * attempt will occur. If dunning has been exhausted, or auto-collection is not enabled for + * this invoice, this field will be `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextAttemptAt(): Optional = nextAttemptAt.getOptional("next_attempt_at") + + /** + * Number of auto-collection payment attempts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numAttempts(): Optional = numAttempts.getOptional("num_attempts") + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field will + * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can be + * used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if + * dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previouslyAttemptedAt(): Optional = + previouslyAttemptedAt.getOptional("previously_attempted_at") + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + /** + * Returns the raw JSON value of [nextAttemptAt]. + * + * Unlike [nextAttemptAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("next_attempt_at") + @ExcludeMissing + fun _nextAttemptAt(): JsonField = nextAttemptAt + + /** + * Returns the raw JSON value of [numAttempts]. + * + * Unlike [numAttempts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_attempts") + @ExcludeMissing + fun _numAttempts(): JsonField = numAttempts + + /** + * Returns the raw JSON value of [previouslyAttemptedAt]. + * + * Unlike [previouslyAttemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previously_attempted_at") + @ExcludeMissing + fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt + + @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 [AutoCollection]. + * + * The following fields are required: + * ```java + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoCollection]. */ + class Builder internal constructor() { + + private var enabled: JsonField? = null + private var nextAttemptAt: JsonField? = null + private var numAttempts: JsonField? = null + private var previouslyAttemptedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoCollection: AutoCollection) = apply { + enabled = autoCollection.enabled + nextAttemptAt = autoCollection.nextAttemptAt + numAttempts = autoCollection.numAttempts + previouslyAttemptedAt = autoCollection.previouslyAttemptedAt + additionalProperties = autoCollection.additionalProperties.toMutableMap() + } + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(enabled: Boolean?) = enabled(JsonField.ofNullable(enabled)) + + /** + * Alias for [Builder.enabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) + + /** Alias for calling [Builder.enabled] with `enabled.orElse(null)`. */ + fun enabled(enabled: Optional) = enabled(enabled.getOrNull()) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the + * next attempt will occur. If dunning has been exhausted, or auto-collection is not + * enabled for this invoice, this field will be `null`. + */ + fun nextAttemptAt(nextAttemptAt: OffsetDateTime?) = + nextAttemptAt(JsonField.ofNullable(nextAttemptAt)) + + /** Alias for calling [Builder.nextAttemptAt] with `nextAttemptAt.orElse(null)`. */ + fun nextAttemptAt(nextAttemptAt: Optional) = + nextAttemptAt(nextAttemptAt.getOrNull()) + + /** + * Sets [Builder.nextAttemptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.nextAttemptAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextAttemptAt(nextAttemptAt: JsonField) = apply { + this.nextAttemptAt = nextAttemptAt + } + + /** Number of auto-collection payment attempts. */ + fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) + + /** + * Alias for [Builder.numAttempts]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) + + /** Alias for calling [Builder.numAttempts] with `numAttempts.orElse(null)`. */ + fun numAttempts(numAttempts: Optional) = numAttempts(numAttempts.getOrNull()) + + /** + * Sets [Builder.numAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.numAttempts] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numAttempts(numAttempts: JsonField) = apply { this.numAttempts = numAttempts } + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field will + * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can + * be used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if + * dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: OffsetDateTime?) = + previouslyAttemptedAt(JsonField.ofNullable(previouslyAttemptedAt)) + + /** + * Alias for calling [Builder.previouslyAttemptedAt] with + * `previouslyAttemptedAt.orElse(null)`. + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: Optional) = + previouslyAttemptedAt(previouslyAttemptedAt.getOrNull()) + + /** + * Sets [Builder.previouslyAttemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.previouslyAttemptedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: JsonField) = apply { + this.previouslyAttemptedAt = previouslyAttemptedAt + } + + 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 [AutoCollection]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoCollection = + AutoCollection( + checkRequired("enabled", enabled), + checkRequired("nextAttemptAt", nextAttemptAt), + checkRequired("numAttempts", numAttempts), + checkRequired("previouslyAttemptedAt", previouslyAttemptedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoCollection = apply { + if (validated) { + return@apply + } + + enabled() + nextAttemptAt() + numAttempts() + previouslyAttemptedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (enabled.asKnown().isPresent) 1 else 0) + + (if (nextAttemptAt.asKnown().isPresent) 1 else 0) + + (if (numAttempts.asKnown().isPresent) 1 else 0) + + (if (previouslyAttemptedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoCollection && + enabled == other.enabled && + nextAttemptAt == other.nextAttemptAt && + numAttempts == other.numAttempts && + previouslyAttemptedAt == other.previouslyAttemptedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabled, + nextAttemptAt, + numAttempts, + previouslyAttemptedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoCollection{enabled=$enabled, nextAttemptAt=$nextAttemptAt, numAttempts=$numAttempts, previouslyAttemptedAt=$previouslyAttemptedAt, additionalProperties=$additionalProperties}" + } + + class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val creditNoteNumber: JsonField, + private val memo: JsonField, + private val reason: JsonField, + private val total: JsonField, + private val type: JsonField, + private val voidedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("credit_note_number") + @ExcludeMissing + creditNoteNumber: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + ) : this(id, creditNoteNumber, memo, reason, total, type, voidedAt, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException 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 creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + + /** + * An optional memo supplied on the credit note. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memo(): Optional = memo.getOptional("memo") + + /** + * @throws OrbInvalidDataException 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 reason(): String = reason.getRequired("reason") + + /** + * @throws OrbInvalidDataException 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 total(): String = total.getRequired("total") + + /** + * @throws OrbInvalidDataException 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 type(): String = type.getRequired("type") + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit note + * was voided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voidedAt(): Optional = voidedAt.getOptional("voided_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [creditNoteNumber]. + * + * Unlike [creditNoteNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_note_number") + @ExcludeMissing + fun _creditNoteNumber(): JsonField = creditNoteNumber + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [voidedAt]. + * + * Unlike [voidedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voided_at") + @ExcludeMissing + fun _voidedAt(): JsonField = voidedAt + + @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 [CreditNote]. + * + * The following fields are required: + * ```java + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditNote]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creditNoteNumber: JsonField? = null + private var memo: JsonField? = null + private var reason: JsonField? = null + private var total: JsonField? = null + private var type: JsonField? = null + private var voidedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditNote: CreditNote) = apply { + id = creditNote.id + creditNoteNumber = creditNote.creditNoteNumber + memo = creditNote.memo + reason = creditNote.reason + total = creditNote.total + type = creditNote.type + voidedAt = creditNote.voidedAt + additionalProperties = creditNote.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun creditNoteNumber(creditNoteNumber: String) = + creditNoteNumber(JsonField.of(creditNoteNumber)) + + /** + * Sets [Builder.creditNoteNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNoteNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNoteNumber(creditNoteNumber: JsonField) = apply { + this.creditNoteNumber = creditNoteNumber + } + + /** An optional memo supplied on the credit note. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** Alias for calling [Builder.memo] with `memo.orElse(null)`. */ + fun memo(memo: Optional) = memo(memo.getOrNull()) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * You should usually call [Builder.memo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun total(total: String) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit + * note was voided. + */ + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** Alias for calling [Builder.voidedAt] with `voidedAt.orElse(null)`. */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.getOrNull()) + + /** + * Sets [Builder.voidedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } + + 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 [CreditNote]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditNote = + CreditNote( + checkRequired("id", id), + checkRequired("creditNoteNumber", creditNoteNumber), + checkRequired("memo", memo), + checkRequired("reason", reason), + checkRequired("total", total), + checkRequired("type", type), + checkRequired("voidedAt", voidedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditNote = apply { + if (validated) { + return@apply + } + + id() + creditNoteNumber() + memo() + reason() + total() + type() + voidedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (creditNoteNumber.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditNote && + id == other.id && + creditNoteNumber == other.creditNoteNumber && + memo == other.memo && + reason == other.reason && + total == other.total && + type == other.type && + voidedAt == other.voidedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creditNoteNumber, + memo, + reason, + total, + type, + voidedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditNote{id=$id, creditNoteNumber=$creditNoteNumber, memo=$memo, reason=$reason, total=$total, type=$type, voidedAt=$voidedAt, additionalProperties=$additionalProperties}" + } + + class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val action: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val creditNote: JsonField, + private val description: JsonField, + private val endingBalance: JsonField, + private val invoice: JsonField, + private val startingBalance: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("action") @ExcludeMissing action: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_note") + @ExcludeMissing + creditNote: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_balance") + @ExcludeMissing + endingBalance: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + @JsonProperty("starting_balance") + @ExcludeMissing + startingBalance: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + mutableMapOf(), + ) + + /** + * A unique id for this transaction. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException 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 action(): Action = action.getRequired("action") + + /** + * The value of the amount changed in the transaction. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The creation time of this transaction. + * + * @throws OrbInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditNote(): Optional = creditNote.getOptional("credit_note") + + /** + * An optional description provided for manual customer balance adjustments. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The new value of the customer's balance prior to the transaction, in the customer's + * currency. + * + * @throws OrbInvalidDataException 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 endingBalance(): String = endingBalance.getRequired("ending_balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * The original value of the customer's balance prior to the transaction, in the customer's + * currency. + * + * @throws OrbInvalidDataException 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 startingBalance(): String = startingBalance.getRequired("starting_balance") + + /** + * @throws OrbInvalidDataException 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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * 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 [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditNote]. + * + * Unlike [creditNote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_note") + @ExcludeMissing + fun _creditNote(): JsonField = creditNote + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [endingBalance]. + * + * Unlike [endingBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance + + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice + + /** + * Returns the raw JSON value of [startingBalance]. + * + * Unlike [startingBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @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 + * [CustomerBalanceTransaction]. + * + * The following fields are required: + * ```java + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerBalanceTransaction]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var action: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditNote: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var invoice: JsonField? = null + private var startingBalance: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerBalanceTransaction: CustomerBalanceTransaction) = apply { + id = customerBalanceTransaction.id + action = customerBalanceTransaction.action + amount = customerBalanceTransaction.amount + createdAt = customerBalanceTransaction.createdAt + creditNote = customerBalanceTransaction.creditNote + description = customerBalanceTransaction.description + endingBalance = customerBalanceTransaction.endingBalance + invoice = customerBalanceTransaction.invoice + startingBalance = customerBalanceTransaction.startingBalance + type = customerBalanceTransaction.type + additionalProperties = + customerBalanceTransaction.additionalProperties.toMutableMap() + } + + /** A unique id for this transaction. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** The value of the amount changed in the transaction. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 creation time of this transaction. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditNote(creditNote: CreditNoteTiny?) = + creditNote(JsonField.ofNullable(creditNote)) + + /** Alias for calling [Builder.creditNote] with `creditNote.orElse(null)`. */ + fun creditNote(creditNote: Optional) = + creditNote(creditNote.getOrNull()) + + /** + * Sets [Builder.creditNote] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNote] with a well-typed [CreditNoteTiny] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNote(creditNote: JsonField) = apply { + this.creditNote = creditNote + } + + /** An optional description provided for manual customer balance adjustments. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * The new value of the customer's balance prior to the transaction, in the customer's + * currency. + */ + fun endingBalance(endingBalance: String) = endingBalance(JsonField.of(endingBalance)) + + /** + * Sets [Builder.endingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBalance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endingBalance(endingBalance: JsonField) = apply { + this.endingBalance = endingBalance + } + + fun invoice(invoice: InvoiceTiny?) = invoice(JsonField.ofNullable(invoice)) + + /** Alias for calling [Builder.invoice] with `invoice.orElse(null)`. */ + fun invoice(invoice: Optional) = invoice(invoice.getOrNull()) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [InvoiceTiny] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + /** + * The original value of the customer's balance prior to the transaction, in the + * customer's currency. + */ + fun startingBalance(startingBalance: String) = + startingBalance(JsonField.of(startingBalance)) + + /** + * Sets [Builder.startingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.startingBalance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [CustomerBalanceTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerBalanceTransaction = + CustomerBalanceTransaction( + checkRequired("id", id), + checkRequired("action", action), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("creditNote", creditNote), + checkRequired("description", description), + checkRequired("endingBalance", endingBalance), + checkRequired("invoice", invoice), + checkRequired("startingBalance", startingBalance), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomerBalanceTransaction = apply { + if (validated) { + return@apply + } + + id() + action().validate() + amount() + createdAt() + creditNote().ifPresent { it.validate() } + description() + endingBalance() + invoice().ifPresent { it.validate() } + startingBalance() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNote.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Action @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 APPLIED_TO_INVOICE = of("applied_to_invoice") + + @JvmField val MANUAL_ADJUSTMENT = of("manual_adjustment") + + @JvmField val PRORATED_REFUND = of("prorated_refund") + + @JvmField val REVERT_PRORATED_REFUND = of("revert_prorated_refund") + + @JvmField val RETURN_FROM_VOIDING = of("return_from_voiding") + + @JvmField val CREDIT_NOTE_APPLIED = of("credit_note_applied") + + @JvmField val CREDIT_NOTE_VOIDED = of("credit_note_voided") + + @JvmField val OVERPAYMENT_REFUND = of("overpayment_refund") + + @JvmField val EXTERNAL_PAYMENT = of("external_payment") + + @JvmField val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + APPLIED_TO_INVOICE, + MANUAL_ADJUSTMENT, + PRORATED_REFUND, + REVERT_PRORATED_REFUND, + RETURN_FROM_VOIDING, + CREDIT_NOTE_APPLIED, + CREDIT_NOTE_VOIDED, + OVERPAYMENT_REFUND, + EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] 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 { + APPLIED_TO_INVOICE, + MANUAL_ADJUSTMENT, + PRORATED_REFUND, + REVERT_PRORATED_REFUND, + RETURN_FROM_VOIDING, + CREDIT_NOTE_APPLIED, + CREDIT_NOTE_VOIDED, + OVERPAYMENT_REFUND, + EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, + /** + * An enum member indicating that [Action] 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) { + APPLIED_TO_INVOICE -> Value.APPLIED_TO_INVOICE + MANUAL_ADJUSTMENT -> Value.MANUAL_ADJUSTMENT + PRORATED_REFUND -> Value.PRORATED_REFUND + REVERT_PRORATED_REFUND -> Value.REVERT_PRORATED_REFUND + RETURN_FROM_VOIDING -> Value.RETURN_FROM_VOIDING + CREDIT_NOTE_APPLIED -> Value.CREDIT_NOTE_APPLIED + CREDIT_NOTE_VOIDED -> Value.CREDIT_NOTE_VOIDED + OVERPAYMENT_REFUND -> Value.OVERPAYMENT_REFUND + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Value.SMALL_INVOICE_CARRYOVER + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPLIED_TO_INVOICE -> Known.APPLIED_TO_INVOICE + MANUAL_ADJUSTMENT -> Known.MANUAL_ADJUSTMENT + PRORATED_REFUND -> Known.PRORATED_REFUND + REVERT_PRORATED_REFUND -> Known.REVERT_PRORATED_REFUND + RETURN_FROM_VOIDING -> Known.RETURN_FROM_VOIDING + CREDIT_NOTE_APPLIED -> Known.CREDIT_NOTE_APPLIED + CREDIT_NOTE_VOIDED -> Known.CREDIT_NOTE_VOIDED + OVERPAYMENT_REFUND -> Known.OVERPAYMENT_REFUND + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Known.SMALL_INVOICE_CARRYOVER + else -> throw OrbInvalidDataException("Unknown Action: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @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 INCREMENT = of("increment") + + @JvmField val DECREMENT = of("decrement") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + INCREMENT, + DECREMENT, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + INCREMENT, + DECREMENT, + /** An enum member indicating that [Type] 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) { + INCREMENT -> Value.INCREMENT + DECREMENT -> Value.DECREMENT + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCREMENT -> Known.INCREMENT + DECREMENT -> Known.DECREMENT + else -> throw OrbInvalidDataException("Unknown Type: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Type && 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 CustomerBalanceTransaction && + id == other.id && + action == other.action && + amount == other.amount && + createdAt == other.createdAt && + creditNote == other.creditNote && + description == other.description && + endingBalance == other.endingBalance && + invoice == other.invoice && + startingBalance == other.startingBalance && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerBalanceTransaction{id=$id, action=$action, amount=$amount, createdAt=$createdAt, creditNote=$creditNote, description=$description, endingBalance=$endingBalance, invoice=$invoice, startingBalance=$startingBalance, type=$type, additionalProperties=$additionalProperties}" + } + + class InvoiceSource @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 SUBSCRIPTION = of("subscription") + + @JvmField val PARTIAL = of("partial") + + @JvmField val ONE_OFF = of("one_off") + + @JvmStatic fun of(value: String) = InvoiceSource(JsonField.of(value)) + } + + /** An enum containing [InvoiceSource]'s known values. */ + enum class Known { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, + } + + /** + * An enum containing [InvoiceSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InvoiceSource] 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 { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, + /** + * An enum member indicating that [InvoiceSource] 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) { + SUBSCRIPTION -> Value.SUBSCRIPTION + PARTIAL -> Value.PARTIAL + ONE_OFF -> Value.ONE_OFF + 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 OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + SUBSCRIPTION -> Known.SUBSCRIPTION + PARTIAL -> Known.PARTIAL + ONE_OFF -> Known.ONE_OFF + else -> throw OrbInvalidDataException("Unknown InvoiceSource: $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 OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): InvoiceSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 InvoiceSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val paymentProvider: JsonField, + private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, + private val succeeded: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_pdf") + @ExcludeMissing + receiptPdf: JsonField = JsonMissing.of(), + @JsonProperty("succeeded") + @ExcludeMissing + succeeded: JsonField = JsonMissing.of(), + ) : this( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + mutableMapOf(), + ) + + /** + * The ID of the payment attempt. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The amount of the payment attempt. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The time at which the payment attempt was created. + * + * @throws OrbInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The payment provider that attempted to collect the payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProvider(): Optional = + paymentProvider.getOptional("payment_provider") + + /** + * The ID of the payment attempt in the payment provider. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProviderId(): Optional = + paymentProviderId.getOptional("payment_provider_id") + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for payment + * attempts that did not succeed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun receiptPdf(): Optional = receiptPdf.getOptional("receipt_pdf") + + /** + * Whether the payment attempt succeeded. + * + * @throws OrbInvalidDataException 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 succeeded(): Boolean = succeeded.getRequired("succeeded") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * 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 [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [paymentProvider]. + * + * Unlike [paymentProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider + + /** + * Returns the raw JSON value of [paymentProviderId]. + * + * Unlike [paymentProviderId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_provider_id") + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId + + /** + * Returns the raw JSON value of [receiptPdf]. + * + * Unlike [receiptPdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("receipt_pdf") + @ExcludeMissing + fun _receiptPdf(): JsonField = receiptPdf + + /** + * Returns the raw JSON value of [succeeded]. + * + * Unlike [succeeded], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("succeeded") @ExcludeMissing fun _succeeded(): JsonField = succeeded + + @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 [PaymentAttempt]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentAttempt]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var paymentProvider: JsonField? = null + private var paymentProviderId: JsonField? = null + private var receiptPdf: JsonField? = null + private var succeeded: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paymentAttempt: PaymentAttempt) = apply { + id = paymentAttempt.id + amount = paymentAttempt.amount + createdAt = paymentAttempt.createdAt + paymentProvider = paymentAttempt.paymentProvider + paymentProviderId = paymentAttempt.paymentProviderId + receiptPdf = paymentAttempt.receiptPdf + succeeded = paymentAttempt.succeeded + additionalProperties = paymentAttempt.additionalProperties.toMutableMap() + } + + /** The ID of the payment attempt. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of the payment attempt. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 time at which the payment attempt was created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** The payment provider that attempted to collect the payment. */ + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** Alias for calling [Builder.paymentProvider] with `paymentProvider.orElse(null)`. */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.getOrNull()) + + /** + * Sets [Builder.paymentProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProvider] with a well-typed [PaymentProvider] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * Alias for calling [Builder.paymentProviderId] with `paymentProviderId.orElse(null)`. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.getOrNull()) + + /** + * Sets [Builder.paymentProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProviderId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for + * payment attempts that did not succeed. + */ + fun receiptPdf(receiptPdf: String?) = receiptPdf(JsonField.ofNullable(receiptPdf)) + + /** Alias for calling [Builder.receiptPdf] with `receiptPdf.orElse(null)`. */ + fun receiptPdf(receiptPdf: Optional) = receiptPdf(receiptPdf.getOrNull()) + + /** + * Sets [Builder.receiptPdf] to an arbitrary JSON value. + * + * You should usually call [Builder.receiptPdf] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun receiptPdf(receiptPdf: JsonField) = apply { this.receiptPdf = receiptPdf } + + /** Whether the payment attempt succeeded. */ + fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) + + /** + * Sets [Builder.succeeded] to an arbitrary JSON value. + * + * You should usually call [Builder.succeeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun succeeded(succeeded: JsonField) = apply { this.succeeded = succeeded } + + 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 [PaymentAttempt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentAttempt = + PaymentAttempt( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("paymentProvider", paymentProvider), + checkRequired("paymentProviderId", paymentProviderId), + checkRequired("receiptPdf", receiptPdf), + checkRequired("succeeded", succeeded), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentAttempt = apply { + if (validated) { + return@apply + } + + id() + amount() + createdAt() + paymentProvider().ifPresent { it.validate() } + paymentProviderId() + receiptPdf() + succeeded() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (if (receiptPdf.asKnown().isPresent) 1 else 0) + + (if (succeeded.asKnown().isPresent) 1 else 0) + + /** The payment provider that attempted to collect the payment. */ + class PaymentProvider + @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 STRIPE = of("stripe") + + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) + } + + /** An enum containing [PaymentProvider]'s known values. */ + enum class Known { + STRIPE + } + + /** + * An enum containing [PaymentProvider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PaymentProvider] 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 { + STRIPE, + /** + * An enum member indicating that [PaymentProvider] 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) { + STRIPE -> Value.STRIPE + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STRIPE -> Known.STRIPE + else -> throw OrbInvalidDataException("Unknown PaymentProvider: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 PaymentProvider && 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 PaymentAttempt && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + receiptPdf == other.receiptPdf && + succeeded == other.succeeded && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, receiptPdf=$receiptPdf, succeeded=$succeeded, additionalProperties=$additionalProperties}" + } + + class Status @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 ISSUED = of("issued") + + @JvmField val PAID = of("paid") + + @JvmField val SYNCED = of("synced") + + @JvmField val VOID = of("void") + + @JvmField val DRAFT = of("draft") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + /** An enum member indicating that [Status] 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) { + ISSUED -> Value.ISSUED + PAID -> Value.PAID + SYNCED -> Value.SYNCED + VOID -> Value.VOID + DRAFT -> Value.DRAFT + 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 OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ISSUED -> Known.ISSUED + PAID -> Known.PAID + SYNCED -> Known.SYNCED + VOID -> Known.VOID + DRAFT -> Known.DRAFT + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 InvoiceIssueSummaryResponse && + id == other.id && + amountDue == other.amountDue && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + createdAt == other.createdAt && + creditNotes == other.creditNotes && + currency == other.currency && + customer == other.customer && + customerBalanceTransactions == other.customerBalanceTransactions && + customerTaxId == other.customerTaxId && + dueDate == other.dueDate && + eligibleToIssueAt == other.eligibleToIssueAt && + hostedInvoiceUrl == other.hostedInvoiceUrl && + invoiceDate == other.invoiceDate && + invoiceNumber == other.invoiceNumber && + invoicePdf == other.invoicePdf && + invoiceSource == other.invoiceSource && + issueFailedAt == other.issueFailedAt && + issuedAt == other.issuedAt && + memo == other.memo && + metadata == other.metadata && + paidAt == other.paidAt && + paymentAttempts == other.paymentAttempts && + paymentFailedAt == other.paymentFailedAt && + paymentStartedAt == other.paymentStartedAt && + scheduledIssueAt == other.scheduledIssueAt && + shippingAddress == other.shippingAddress && + status == other.status && + subscription == other.subscription && + syncFailedAt == other.syncFailedAt && + total == other.total && + voidedAt == other.voidedAt && + willAutoIssue == other.willAutoIssue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + issueFailedAt, + issuedAt, + memo, + metadata, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoiceIssueSummaryResponse{id=$id, amountDue=$amountDue, autoCollection=$autoCollection, billingAddress=$billingAddress, createdAt=$createdAt, creditNotes=$creditNotes, currency=$currency, customer=$customer, customerBalanceTransactions=$customerBalanceTransactions, customerTaxId=$customerTaxId, dueDate=$dueDate, eligibleToIssueAt=$eligibleToIssueAt, hostedInvoiceUrl=$hostedInvoiceUrl, invoiceDate=$invoiceDate, invoiceNumber=$invoiceNumber, invoicePdf=$invoicePdf, invoiceSource=$invoiceSource, issueFailedAt=$issueFailedAt, issuedAt=$issuedAt, memo=$memo, metadata=$metadata, paidAt=$paidAt, paymentAttempts=$paymentAttempts, paymentFailedAt=$paymentFailedAt, paymentStartedAt=$paymentStartedAt, scheduledIssueAt=$scheduledIssueAt, shippingAddress=$shippingAddress, status=$status, subscription=$subscription, syncFailedAt=$syncFailedAt, total=$total, voidedAt=$voidedAt, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryResponse.kt index 64ec70dca..f791ced25 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryResponse.kt @@ -355,6 +355,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1262,6 +1263,7 @@ private constructor( * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index eb12e7a91..ae9cacbc5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -34,13 +34,13 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and `invoice_date` - * properties on an invoice. If you pass null for the metadata value, it will clear any existing - * metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, and + * `auto_collection` properties on an invoice. If you pass null for the metadata value, it will + * clear any existing metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can only - * be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` can only be modified if the invoice is in a `draft` state. `invoice_date` + * can only be modified for non-subscription invoices. */ class InvoiceUpdateParams private constructor( @@ -52,6 +52,16 @@ private constructor( fun invoiceId(): Optional = Optional.ofNullable(invoiceId) + /** + * Determines whether this invoice will automatically attempt to charge a saved payment method, + * if any. Can only be modified on draft invoices. If not specified, the invoice's existing + * setting is unchanged. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoCollection(): Optional = body.autoCollection() + /** * An optional custom due date for the invoice. If not set, the due date will be calculated * based on the `net_terms` value. @@ -91,6 +101,13 @@ private constructor( */ fun netTerms(): Optional = body.netTerms() + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoCollection(): JsonField = body._autoCollection() + /** * Returns the raw JSON value of [dueDate]. * @@ -163,13 +180,44 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [autoCollection] * - [dueDate] * - [invoiceDate] * - [metadata] * - [netTerms] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the invoice's + * existing setting is unchanged. + */ + fun autoCollection(autoCollection: Boolean?) = apply { body.autoCollection(autoCollection) } + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + /** * An optional custom due date for the invoice. If not set, the due date will be calculated * based on the `net_terms` value. @@ -408,6 +456,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val autoCollection: JsonField, private val dueDate: JsonField, private val invoiceDate: JsonField, private val metadata: JsonField, @@ -417,6 +466,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), @JsonProperty("due_date") @ExcludeMissing dueDate: JsonField = JsonMissing.of(), @@ -427,7 +479,17 @@ private constructor( @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), - ) : this(dueDate, invoiceDate, metadata, netTerms, mutableMapOf()) + ) : this(autoCollection, dueDate, invoiceDate, metadata, netTerms, mutableMapOf()) + + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the invoice's + * existing setting is unchanged. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Optional = autoCollection.getOptional("auto_collection") /** * An optional custom due date for the invoice. If not set, the due date will be calculated @@ -468,6 +530,16 @@ private constructor( */ fun netTerms(): Optional = netTerms.getOptional("net_terms") + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + /** * Returns the raw JSON value of [dueDate]. * @@ -519,6 +591,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var autoCollection: JsonField = JsonMissing.of() private var dueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() @@ -527,6 +600,7 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { + autoCollection = body.autoCollection dueDate = body.dueDate invoiceDate = body.invoiceDate metadata = body.metadata @@ -534,6 +608,36 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the + * invoice's existing setting is unchanged. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + /** * An optional custom due date for the invoice. If not set, the due date will be * calculated based on the `net_terms` value. @@ -656,7 +760,14 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Body = - Body(dueDate, invoiceDate, metadata, netTerms, additionalProperties.toMutableMap()) + Body( + autoCollection, + dueDate, + invoiceDate, + metadata, + netTerms, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -666,6 +777,7 @@ private constructor( return@apply } + autoCollection() dueDate().ifPresent { it.validate() } invoiceDate().ifPresent { it.validate() } metadata().ifPresent { it.validate() } @@ -689,7 +801,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (dueDate.asKnown().getOrNull()?.validity() ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (dueDate.asKnown().getOrNull()?.validity() ?: 0) + (invoiceDate.asKnown().getOrNull()?.validity() ?: 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) @@ -700,6 +813,7 @@ private constructor( } return other is Body && + autoCollection == other.autoCollection && dueDate == other.dueDate && invoiceDate == other.invoiceDate && metadata == other.metadata && @@ -708,13 +822,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(dueDate, invoiceDate, metadata, netTerms, additionalProperties) + Objects.hash( + autoCollection, + dueDate, + invoiceDate, + metadata, + netTerms, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{dueDate=$dueDate, invoiceDate=$invoiceDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" + "Body{autoCollection=$autoCollection, dueDate=$dueDate, invoiceDate=$invoiceDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" } /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt index 47f387c3c..b8655925b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -622,6 +622,8 @@ private constructor( @JvmField val NUMERAL = of("numeral") + @JvmField val STRIPE_TAX = of("stripe_tax") + @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -635,6 +637,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, } /** @@ -657,6 +660,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -681,6 +685,7 @@ private constructor( AVALARA -> Value.AVALARA ANROK -> Value.ANROK NUMERAL -> Value.NUMERAL + STRIPE_TAX -> Value.STRIPE_TAX else -> Value._UNKNOWN } @@ -703,6 +708,7 @@ private constructor( AVALARA -> Known.AVALARA ANROK -> Known.ANROK NUMERAL -> Known.NUMERAL + STRIPE_TAX -> Known.STRIPE_TAX else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index a7e8634c9..9f99f3403 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -828,6 +828,8 @@ private constructor( @JvmField val NUMERAL = of("numeral") + @JvmField val STRIPE_TAX = of("stripe_tax") + @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -841,6 +843,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, } /** @@ -863,6 +866,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -887,6 +891,7 @@ private constructor( AVALARA -> Value.AVALARA ANROK -> Value.ANROK NUMERAL -> Value.NUMERAL + STRIPE_TAX -> Value.STRIPE_TAX else -> Value._UNKNOWN } @@ -909,6 +914,7 @@ private constructor( AVALARA -> Known.AVALARA ANROK -> Known.ANROK NUMERAL -> Known.NUMERAL + STRIPE_TAX -> Known.STRIPE_TAX else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt new file mode 100644 index 000000000..62de25dfa --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt @@ -0,0 +1,761 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified date + * in the customer's timezone. Otherwise, the activation time will default to the **start** of the + * current day in the customer's timezone. + */ +class LicenseCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The external identifier for the license. + * + * @throws OrbInvalidDataException 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 externalLicenseId(): String = body.externalLicenseId() + + /** + * @throws OrbInvalidDataException 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 licenseTypeId(): String = body.licenseTypeId() + + /** + * @throws OrbInvalidDataException 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 subscriptionId(): String = body.subscriptionId() + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = body.endDate() + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun startDate(): Optional = body.startDate() + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _externalLicenseId(): JsonField = body._externalLicenseId() + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _licenseTypeId(): JsonField = body._licenseTypeId() + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _subscriptionId(): JsonField = body._subscriptionId() + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endDate(): JsonField = body._endDate() + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startDate(): JsonField = body._startDate() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseCreateParams]. + * + * The following fields are required: + * ```java + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseCreateParams: LicenseCreateParams) = apply { + body = licenseCreateParams.body.toBuilder() + additionalHeaders = licenseCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [externalLicenseId] + * - [licenseTypeId] + * - [subscriptionId] + * - [endDate] + * - [startDate] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The external identifier for the license. */ + fun externalLicenseId(externalLicenseId: String) = apply { + body.externalLicenseId(externalLicenseId) + } + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + body.externalLicenseId(externalLicenseId) + } + + fun licenseTypeId(licenseTypeId: String) = apply { body.licenseTypeId(licenseTypeId) } + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + body.licenseTypeId(licenseTypeId) + } + + fun subscriptionId(subscriptionId: String) = apply { body.subscriptionId(subscriptionId) } + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + body.subscriptionId(subscriptionId) + } + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + */ + fun endDate(endDate: LocalDate?) = apply { body.endDate(endDate) } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + */ + fun startDate(startDate: LocalDate?) = apply { body.startDate(startDate) } + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseCreateParams = + LicenseCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val subscriptionId: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + externalLicenseId, + licenseTypeId, + subscriptionId, + endDate, + startDate, + mutableMapOf(), + ) + + /** + * The external identifier for the license. + * + * @throws OrbInvalidDataException 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 externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startDate(): Optional = startDate.getOptional("start_date") + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @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 [Body]. + * + * The following fields are required: + * ```java + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var subscriptionId: JsonField? = null + private var endDate: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + externalLicenseId = body.externalLicenseId + licenseTypeId = body.licenseTypeId + subscriptionId = body.subscriptionId + endDate = body.endDate + startDate = body.startDate + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The external identifier for the license. */ + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + */ + fun endDate(endDate: LocalDate?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + */ + fun startDate(startDate: LocalDate?) = startDate(JsonField.ofNullable(startDate)) + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + endDate, + startDate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + externalLicenseId() + licenseTypeId() + subscriptionId() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + endDate == other.endDate && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + endDate, + startDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt new file mode 100644 index 000000000..75237ed96 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt @@ -0,0 +1,552 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException 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 externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException 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 startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @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 [LicenseCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseCreateResponse: LicenseCreateResponse) = apply { + id = licenseCreateResponse.id + endDate = licenseCreateResponse.endDate + externalLicenseId = licenseCreateResponse.externalLicenseId + licenseTypeId = licenseCreateResponse.licenseTypeId + startDate = licenseCreateResponse.startDate + status = licenseCreateResponse.status + subscriptionId = licenseCreateResponse.subscriptionId + additionalProperties = licenseCreateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + 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 [LicenseCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseCreateResponse = + LicenseCreateResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseCreateResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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 OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 LicenseCreateResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseCreateResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt new file mode 100644 index 000000000..a36a7915f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt @@ -0,0 +1,432 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** of + * the current day in the customer's timezone. + */ +class LicenseDeactivateParams +private constructor( + private val licenseId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): Optional = Optional.ofNullable(licenseId) + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = body.endDate() + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endDate(): JsonField = body._endDate() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseDeactivateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseDeactivateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseDeactivateParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseDeactivateParams: LicenseDeactivateParams) = apply { + licenseId = licenseDeactivateParams.licenseId + body = licenseDeactivateParams.body.toBuilder() + additionalHeaders = licenseDeactivateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseDeactivateParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [endDate] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + */ + fun endDate(endDate: LocalDate?) = apply { body.endDate(endDate) } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseDeactivateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseDeactivateParams = + LicenseDeactivateParams( + licenseId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of() + ) : this(endDate, mutableMapOf()) + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @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 [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + endDate = body.endDate + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in + * the customer's timezone. + */ + fun endDate(endDate: LocalDate?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(endDate, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + endDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (endDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + endDate == other.endDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{endDate=$endDate, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseDeactivateParams && + licenseId == other.licenseId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(licenseId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseDeactivateParams{licenseId=$licenseId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt new file mode 100644 index 000000000..88150674f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt @@ -0,0 +1,552 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseDeactivateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException 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 externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException 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 startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @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 [LicenseDeactivateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseDeactivateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseDeactivateResponse: LicenseDeactivateResponse) = apply { + id = licenseDeactivateResponse.id + endDate = licenseDeactivateResponse.endDate + externalLicenseId = licenseDeactivateResponse.externalLicenseId + licenseTypeId = licenseDeactivateResponse.licenseTypeId + startDate = licenseDeactivateResponse.startDate + status = licenseDeactivateResponse.status + subscriptionId = licenseDeactivateResponse.subscriptionId + additionalProperties = licenseDeactivateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + 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 [LicenseDeactivateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseDeactivateResponse = + LicenseDeactivateResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseDeactivateResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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 OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 LicenseDeactivateResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseDeactivateResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt new file mode 100644 index 000000000..83028e31c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseExternalLicenseGetUsageParams +private constructor( + private val externalLicenseId: String?, + private val licenseTypeId: String, + private val subscriptionId: String, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun externalLicenseId(): Optional = Optional.ofNullable(externalLicenseId) + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(): String = licenseTypeId + + /** The subscription ID to get license usage for. */ + fun subscriptionId(): String = subscriptionId + + /** Pagination cursor from a previous request. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): Optional = Optional.ofNullable(endDate) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): Optional> = Optional.ofNullable(groupBy) + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): Optional = Optional.ofNullable(startDate) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseExternalLicenseGetUsageParams]. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseExternalLicenseGetUsageParams]. */ + class Builder internal constructor() { + + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + licenseExternalLicenseGetUsageParams: LicenseExternalLicenseGetUsageParams + ) = apply { + externalLicenseId = licenseExternalLicenseGetUsageParams.externalLicenseId + licenseTypeId = licenseExternalLicenseGetUsageParams.licenseTypeId + subscriptionId = licenseExternalLicenseGetUsageParams.subscriptionId + cursor = licenseExternalLicenseGetUsageParams.cursor + endDate = licenseExternalLicenseGetUsageParams.endDate + groupBy = licenseExternalLicenseGetUsageParams.groupBy?.toMutableList() + limit = licenseExternalLicenseGetUsageParams.limit + startDate = licenseExternalLicenseGetUsageParams.startDate + additionalHeaders = licenseExternalLicenseGetUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = + licenseExternalLicenseGetUsageParams.additionalQueryParams.toBuilder() + } + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + /** Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The subscription ID to get license usage for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional>) = groupBy(groupBy.getOrNull()) + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseExternalLicenseGetUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseExternalLicenseGetUsageParams = + LicenseExternalLicenseGetUsageParams( + externalLicenseId, + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> externalLicenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseExternalLicenseGetUsageParams && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseExternalLicenseGetUsageParams{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt new file mode 100644 index 000000000..4082b8879 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt @@ -0,0 +1,963 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseExternalLicenseGetUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException 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 paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @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 + * [LicenseExternalLicenseGetUsageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseExternalLicenseGetUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + licenseExternalLicenseGetUsageResponse: LicenseExternalLicenseGetUsageResponse + ) = apply { + data = licenseExternalLicenseGetUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseExternalLicenseGetUsageResponse.paginationMetadata + additionalProperties = + licenseExternalLicenseGetUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + 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 [LicenseExternalLicenseGetUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseExternalLicenseGetUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the period. + * + * @throws OrbInvalidDataException 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 allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the period. + * + * @throws OrbInvalidDataException 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 consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage period. + * + * @throws OrbInvalidDataException 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 endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException 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 pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException 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 remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage period. + * + * @throws OrbInvalidDataException 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 startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Optional = + allocationEligibleCredits.getOptional("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): Optional = + externalLicenseId.getOptional("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): Optional = licenseId.getOptional("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Optional = + sharedPoolCredits.getOptional("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @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 [Data]. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Alias for calling [Builder.allocationEligibleCredits] with + * `allocationEligibleCredits.orElse(null)`. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Optional) = + allocationEligibleCredits(allocationEligibleCredits.getOrNull()) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. + */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Alias for calling [Builder.sharedPoolCredits] with `sharedPoolCredits.orElse(null)`. + */ + fun sharedPoolCredits(sharedPoolCredits: Optional) = + sharedPoolCredits(sharedPoolCredits.getOrNull()) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocatedCredits.asKnown().isPresent) 1 else 0) + + (if (consumedCredits.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (pricingUnit.asKnown().isPresent) 1 else 0) + + (if (remainingCredits.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (allocationEligibleCredits.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseId.asKnown().isPresent) 1 else 0) + + (if (sharedPoolCredits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseExternalLicenseGetUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseExternalLicenseGetUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt new file mode 100644 index 000000000..9a7b44475 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page +import com.withorb.api.core.checkRequired +import com.withorb.api.services.blocking.LicenseService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see LicenseService.list */ +class LicenseListPage +private constructor( + private val service: LicenseService, + private val params: LicenseListParams, + private val response: LicenseListPageResponse, +) : Page { + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.paginationMetadata + */ + fun paginationMetadata(): Optional = + response._paginationMetadata().getOptional("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + + fun nextPageParams(): LicenseListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): LicenseListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): LicenseListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListPage]. */ + class Builder internal constructor() { + + private var service: LicenseService? = null + private var params: LicenseListParams? = null + private var response: LicenseListPageResponse? = null + + @JvmSynthetic + internal fun from(licenseListPage: LicenseListPage) = apply { + service = licenseListPage.service + params = licenseListPage.params + response = licenseListPage.response + } + + fun service(service: LicenseService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPage = + LicenseListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "LicenseListPage{service=$service, params=$params, response=$response}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt new file mode 100644 index 000000000..e0d605def --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync +import com.withorb.api.core.checkRequired +import com.withorb.api.services.async.LicenseServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see LicenseServiceAsync.list */ +class LicenseListPageAsync +private constructor( + private val service: LicenseServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: LicenseListParams, + private val response: LicenseListPageResponse, +) : PageAsync { + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.paginationMetadata + */ + fun paginationMetadata(): Optional = + response._paginationMetadata().getOptional("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + + fun nextPageParams(): LicenseListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): LicenseListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListPageAsync]. */ + class Builder internal constructor() { + + private var service: LicenseServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: LicenseListParams? = null + private var response: LicenseListPageResponse? = null + + @JvmSynthetic + internal fun from(licenseListPageAsync: LicenseListPageAsync) = apply { + service = licenseListPageAsync.service + streamHandlerExecutor = licenseListPageAsync.streamHandlerExecutor + params = licenseListPageAsync.params + response = licenseListPageAsync.response + } + + fun service(service: LicenseServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPageAsync = + LicenseListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "LicenseListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt new file mode 100644 index 000000000..314b0b112 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class LicenseListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException 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 paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @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 [LicenseListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseListPageResponse: LicenseListPageResponse) = apply { + data = licenseListPageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseListPageResponse.paginationMetadata + additionalProperties = licenseListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseListResponse] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: LicenseListResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + 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 [LicenseListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPageResponse = + LicenseListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseListPageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt new file mode 100644 index 000000000..d28a59325 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt @@ -0,0 +1,427 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.withorb.api.core.Enum +import com.withorb.api.core.JsonField +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This endpoint returns a list of all licenses for a subscription. */ +class LicenseListParams +private constructor( + private val subscriptionId: String, + private val cursor: String?, + private val externalLicenseId: String?, + private val licenseTypeId: String?, + private val limit: Long?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun subscriptionId(): String = subscriptionId + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + fun externalLicenseId(): Optional = Optional.ofNullable(externalLicenseId) + + fun licenseTypeId(): Optional = Optional.ofNullable(licenseTypeId) + + /** The number of items to fetch. Defaults to 20. */ + fun limit(): Optional = Optional.ofNullable(limit) + + fun status(): Optional = Optional.ofNullable(status) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListParams]. */ + class Builder internal constructor() { + + private var subscriptionId: String? = null + private var cursor: String? = null + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var limit: Long? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseListParams: LicenseListParams) = apply { + subscriptionId = licenseListParams.subscriptionId + cursor = licenseListParams.cursor + externalLicenseId = licenseListParams.externalLicenseId + licenseTypeId = licenseListParams.licenseTypeId + limit = licenseListParams.limit + status = licenseListParams.status + additionalHeaders = licenseListParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseListParams.additionalQueryParams.toBuilder() + } + + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + /** Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + fun licenseTypeId(licenseTypeId: String?) = apply { this.licenseTypeId = licenseTypeId } + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** The number of items to fetch. Defaults to 20. */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListParams = + LicenseListParams( + checkRequired("subscriptionId", subscriptionId), + cursor, + externalLicenseId, + licenseTypeId, + limit, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + externalLicenseId?.let { put("external_license_id", it) } + licenseTypeId?.let { put("license_type_id", it) } + limit?.let { put("limit", it.toString()) } + status?.let { put("status", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class Status @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 ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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 OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 LicenseListParams && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + limit == other.limit && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + subscriptionId, + cursor, + externalLicenseId, + licenseTypeId, + limit, + status, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseListParams{subscriptionId=$subscriptionId, cursor=$cursor, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt new file mode 100644 index 000000000..2e884a670 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt @@ -0,0 +1,552 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException 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 externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException 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 startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @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 [LicenseListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseListResponse: LicenseListResponse) = apply { + id = licenseListResponse.id + endDate = licenseListResponse.endDate + externalLicenseId = licenseListResponse.externalLicenseId + licenseTypeId = licenseListResponse.licenseTypeId + startDate = licenseListResponse.startDate + status = licenseListResponse.status + subscriptionId = licenseListResponse.subscriptionId + additionalProperties = licenseListResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + 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 [LicenseListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListResponse = + LicenseListResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseListResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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 OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 LicenseListResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseListResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt new file mode 100644 index 000000000..0f9be2744 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This endpoint is used to fetch a license given an external license identifier. */ +class LicenseRetrieveByExternalIdParams +private constructor( + private val externalLicenseId: String?, + private val licenseTypeId: String, + private val subscriptionId: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun externalLicenseId(): Optional = Optional.ofNullable(externalLicenseId) + + /** The ID of the license type to fetch the license for. */ + fun licenseTypeId(): String = licenseTypeId + + /** The ID of the subscription to fetch the license for. */ + fun subscriptionId(): String = subscriptionId + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseRetrieveByExternalIdParams]. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveByExternalIdParams]. */ + class Builder internal constructor() { + + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseRetrieveByExternalIdParams: LicenseRetrieveByExternalIdParams) = + apply { + externalLicenseId = licenseRetrieveByExternalIdParams.externalLicenseId + licenseTypeId = licenseRetrieveByExternalIdParams.licenseTypeId + subscriptionId = licenseRetrieveByExternalIdParams.subscriptionId + additionalHeaders = licenseRetrieveByExternalIdParams.additionalHeaders.toBuilder() + additionalQueryParams = + licenseRetrieveByExternalIdParams.additionalQueryParams.toBuilder() + } + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + /** Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** The ID of the license type to fetch the license for. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The ID of the subscription to fetch the license for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseRetrieveByExternalIdParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveByExternalIdParams = + LicenseRetrieveByExternalIdParams( + externalLicenseId, + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> externalLicenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveByExternalIdParams && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseRetrieveByExternalIdParams{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt new file mode 100644 index 000000000..44bb63278 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt @@ -0,0 +1,556 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseRetrieveByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException 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 externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException 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 startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @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 + * [LicenseRetrieveByExternalIdResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveByExternalIdResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + licenseRetrieveByExternalIdResponse: LicenseRetrieveByExternalIdResponse + ) = apply { + id = licenseRetrieveByExternalIdResponse.id + endDate = licenseRetrieveByExternalIdResponse.endDate + externalLicenseId = licenseRetrieveByExternalIdResponse.externalLicenseId + licenseTypeId = licenseRetrieveByExternalIdResponse.licenseTypeId + startDate = licenseRetrieveByExternalIdResponse.startDate + status = licenseRetrieveByExternalIdResponse.status + subscriptionId = licenseRetrieveByExternalIdResponse.subscriptionId + additionalProperties = + licenseRetrieveByExternalIdResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + 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 [LicenseRetrieveByExternalIdResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseRetrieveByExternalIdResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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 OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 LicenseRetrieveByExternalIdResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseRetrieveByExternalIdResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt new file mode 100644 index 000000000..c52fd1280 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This endpoint is used to fetch a license given an identifier. */ +class LicenseRetrieveParams +private constructor( + private val licenseId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): Optional = Optional.ofNullable(licenseId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseRetrieveParams: LicenseRetrieveParams) = apply { + licenseId = licenseRetrieveParams.licenseId + additionalHeaders = licenseRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseRetrieveParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseRetrieveParams = + LicenseRetrieveParams( + licenseId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveParams && + licenseId == other.licenseId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(licenseId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseRetrieveParams{licenseId=$licenseId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt new file mode 100644 index 000000000..1be48490b --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt @@ -0,0 +1,552 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException 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 externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException 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 startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @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 [LicenseRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseRetrieveResponse: LicenseRetrieveResponse) = apply { + id = licenseRetrieveResponse.id + endDate = licenseRetrieveResponse.endDate + externalLicenseId = licenseRetrieveResponse.externalLicenseId + licenseTypeId = licenseRetrieveResponse.licenseTypeId + startDate = licenseRetrieveResponse.startDate + status = licenseRetrieveResponse.status + subscriptionId = licenseRetrieveResponse.subscriptionId + additionalProperties = licenseRetrieveResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + 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 [LicenseRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveResponse = + LicenseRetrieveResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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 OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $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 OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 Status && 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 LicenseRetrieveResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseRetrieveResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt new file mode 100644 index 000000000..cc24d864f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt @@ -0,0 +1,505 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ +class LicenseTypeCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = body.groupingKey() + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = body.name() + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _groupingKey(): JsonField = body._groupingKey() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeCreateParams]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseTypeCreateParams: LicenseTypeCreateParams) = apply { + body = licenseTypeCreateParams.body.toBuilder() + additionalHeaders = licenseTypeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [groupingKey] + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = apply { body.groupingKey(groupingKey) } + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { body.groupingKey(groupingKey) } + + /** The name of the license type. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeCreateParams = + LicenseTypeCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(groupingKey, name, mutableMapOf()) + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [Body]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + groupingKey = body.groupingKey + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt new file mode 100644 index 000000000..46ff3bd95 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseTypeCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseTypeCreateResponse: LicenseTypeCreateResponse) = apply { + id = licenseTypeCreateResponse.id + groupingKey = licenseTypeCreateResponse.groupingKey + name = licenseTypeCreateResponse.name + additionalProperties = licenseTypeCreateResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseTypeCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeCreateResponse = + LicenseTypeCreateResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseTypeCreateResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeCreateResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeCreateResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt new file mode 100644 index 000000000..56cf27b4a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page +import com.withorb.api.core.checkRequired +import com.withorb.api.services.blocking.LicenseTypeService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see LicenseTypeService.list */ +class LicenseTypeListPage +private constructor( + private val service: LicenseTypeService, + private val params: LicenseTypeListParams, + private val response: LicenseTypeListPageResponse, +) : Page { + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.paginationMetadata + */ + fun paginationMetadata(): Optional = + response._paginationMetadata().getOptional("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + + fun nextPageParams(): LicenseTypeListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): LicenseTypeListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): LicenseTypeListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseTypeListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPage]. */ + class Builder internal constructor() { + + private var service: LicenseTypeService? = null + private var params: LicenseTypeListParams? = null + private var response: LicenseTypeListPageResponse? = null + + @JvmSynthetic + internal fun from(licenseTypeListPage: LicenseTypeListPage) = apply { + service = licenseTypeListPage.service + params = licenseTypeListPage.params + response = licenseTypeListPage.response + } + + fun service(service: LicenseTypeService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseTypeListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseTypeListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseTypeListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPage = + LicenseTypeListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "LicenseTypeListPage{service=$service, params=$params, response=$response}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt new file mode 100644 index 000000000..ba5b17e26 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync +import com.withorb.api.core.checkRequired +import com.withorb.api.services.async.LicenseTypeServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see LicenseTypeServiceAsync.list */ +class LicenseTypeListPageAsync +private constructor( + private val service: LicenseTypeServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: LicenseTypeListParams, + private val response: LicenseTypeListPageResponse, +) : PageAsync { + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.paginationMetadata + */ + fun paginationMetadata(): Optional = + response._paginationMetadata().getOptional("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + + fun nextPageParams(): LicenseTypeListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): LicenseTypeListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseTypeListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPageAsync]. */ + class Builder internal constructor() { + + private var service: LicenseTypeServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: LicenseTypeListParams? = null + private var response: LicenseTypeListPageResponse? = null + + @JvmSynthetic + internal fun from(licenseTypeListPageAsync: LicenseTypeListPageAsync) = apply { + service = licenseTypeListPageAsync.service + streamHandlerExecutor = licenseTypeListPageAsync.streamHandlerExecutor + params = licenseTypeListPageAsync.params + response = licenseTypeListPageAsync.response + } + + fun service(service: LicenseTypeServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseTypeListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseTypeListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseTypeListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPageAsync = + LicenseTypeListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "LicenseTypeListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt new file mode 100644 index 000000000..e2005620f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class LicenseTypeListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException 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 paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @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 [LicenseTypeListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseTypeListPageResponse: LicenseTypeListPageResponse) = apply { + data = licenseTypeListPageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseTypeListPageResponse.paginationMetadata + additionalProperties = licenseTypeListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseTypeListResponse] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: LicenseTypeListResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + 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 [LicenseTypeListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPageResponse = + LicenseTypeListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseTypeListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeListPageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt new file mode 100644 index 000000000..2d82ad755 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint returns a list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ +class LicenseTypeListParams +private constructor( + private val cursor: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** The number of items to fetch. Defaults to 20. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseTypeListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseTypeListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseTypeListParams: LicenseTypeListParams) = apply { + cursor = licenseTypeListParams.cursor + limit = licenseTypeListParams.limit + additionalHeaders = licenseTypeListParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeListParams.additionalQueryParams.toBuilder() + } + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** The number of items to fetch. Defaults to 20. */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseTypeListParams = + LicenseTypeListParams( + cursor, + limit, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListParams && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt new file mode 100644 index 000000000..d6de93d06 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseTypeListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseTypeListResponse: LicenseTypeListResponse) = apply { + id = licenseTypeListResponse.id + groupingKey = licenseTypeListResponse.groupingKey + name = licenseTypeListResponse.name + additionalProperties = licenseTypeListResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseTypeListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListResponse = + LicenseTypeListResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseTypeListResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeListResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt new file mode 100644 index 000000000..958de0d5f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt @@ -0,0 +1,202 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint returns a license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ +class LicenseTypeRetrieveParams +private constructor( + private val licenseTypeId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseTypeId(): Optional = Optional.ofNullable(licenseTypeId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseTypeRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeRetrieveParams]. */ + class Builder internal constructor() { + + private var licenseTypeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseTypeRetrieveParams: LicenseTypeRetrieveParams) = apply { + licenseTypeId = licenseTypeRetrieveParams.licenseTypeId + additionalHeaders = licenseTypeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeRetrieveParams.additionalQueryParams.toBuilder() + } + + fun licenseTypeId(licenseTypeId: String?) = apply { this.licenseTypeId = licenseTypeId } + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseTypeRetrieveParams = + LicenseTypeRetrieveParams( + licenseTypeId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseTypeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeRetrieveParams && + licenseTypeId == other.licenseTypeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(licenseTypeId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeRetrieveParams{licenseTypeId=$licenseTypeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt new file mode 100644 index 000000000..7024ecdc0 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseTypeRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseTypeRetrieveResponse: LicenseTypeRetrieveResponse) = apply { + id = licenseTypeRetrieveResponse.id + groupingKey = licenseTypeRetrieveResponse.groupingKey + name = licenseTypeRetrieveResponse.name + additionalProperties = licenseTypeRetrieveResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseTypeRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseTypeRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeRetrieveResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeRetrieveResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt new file mode 100644 index 000000000..941a47d15 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt @@ -0,0 +1,341 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.checkRequired +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseUsageGetAllUsageParams +private constructor( + private val licenseTypeId: String, + private val subscriptionId: String, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(): String = licenseTypeId + + /** The subscription ID to get license usage for. */ + fun subscriptionId(): String = subscriptionId + + /** Pagination cursor from a previous request. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): Optional = Optional.ofNullable(endDate) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): Optional> = Optional.ofNullable(groupBy) + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): Optional = Optional.ofNullable(startDate) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseUsageGetAllUsageParams]. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetAllUsageParams]. */ + class Builder internal constructor() { + + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseUsageGetAllUsageParams: LicenseUsageGetAllUsageParams) = apply { + licenseTypeId = licenseUsageGetAllUsageParams.licenseTypeId + subscriptionId = licenseUsageGetAllUsageParams.subscriptionId + cursor = licenseUsageGetAllUsageParams.cursor + endDate = licenseUsageGetAllUsageParams.endDate + groupBy = licenseUsageGetAllUsageParams.groupBy?.toMutableList() + limit = licenseUsageGetAllUsageParams.limit + startDate = licenseUsageGetAllUsageParams.startDate + additionalHeaders = licenseUsageGetAllUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseUsageGetAllUsageParams.additionalQueryParams.toBuilder() + } + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The subscription ID to get license usage for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional>) = groupBy(groupBy.getOrNull()) + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseUsageGetAllUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetAllUsageParams = + LicenseUsageGetAllUsageParams( + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetAllUsageParams && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + licenseTypeId, + subscriptionId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseUsageGetAllUsageParams{licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt new file mode 100644 index 000000000..1f0c28ad8 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt @@ -0,0 +1,962 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseUsageGetAllUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException 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 paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @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 + * [LicenseUsageGetAllUsageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetAllUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseUsageGetAllUsageResponse: LicenseUsageGetAllUsageResponse) = + apply { + data = licenseUsageGetAllUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseUsageGetAllUsageResponse.paginationMetadata + additionalProperties = + licenseUsageGetAllUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + 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 [LicenseUsageGetAllUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseUsageGetAllUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the period. + * + * @throws OrbInvalidDataException 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 allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the period. + * + * @throws OrbInvalidDataException 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 consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage period. + * + * @throws OrbInvalidDataException 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 endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException 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 pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException 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 remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage period. + * + * @throws OrbInvalidDataException 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 startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Optional = + allocationEligibleCredits.getOptional("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): Optional = + externalLicenseId.getOptional("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): Optional = licenseId.getOptional("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Optional = + sharedPoolCredits.getOptional("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @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 [Data]. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Alias for calling [Builder.allocationEligibleCredits] with + * `allocationEligibleCredits.orElse(null)`. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Optional) = + allocationEligibleCredits(allocationEligibleCredits.getOrNull()) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. + */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Alias for calling [Builder.sharedPoolCredits] with `sharedPoolCredits.orElse(null)`. + */ + fun sharedPoolCredits(sharedPoolCredits: Optional) = + sharedPoolCredits(sharedPoolCredits.getOrNull()) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocatedCredits.asKnown().isPresent) 1 else 0) + + (if (consumedCredits.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (pricingUnit.asKnown().isPresent) 1 else 0) + + (if (remainingCredits.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (allocationEligibleCredits.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseId.asKnown().isPresent) 1 else 0) + + (if (sharedPoolCredits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetAllUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseUsageGetAllUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt new file mode 100644 index 000000000..8a1701ee0 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseUsageGetUsageParams +private constructor( + private val licenseId: String?, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): Optional = Optional.ofNullable(licenseId) + + /** Pagination cursor from a previous request. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): Optional = Optional.ofNullable(endDate) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): Optional> = Optional.ofNullable(groupBy) + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): Optional = Optional.ofNullable(startDate) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseUsageGetUsageParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [LicenseUsageGetUsageParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetUsageParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseUsageGetUsageParams: LicenseUsageGetUsageParams) = apply { + licenseId = licenseUsageGetUsageParams.licenseId + cursor = licenseUsageGetUsageParams.cursor + endDate = licenseUsageGetUsageParams.endDate + groupBy = licenseUsageGetUsageParams.groupBy?.toMutableList() + limit = licenseUsageGetUsageParams.limit + startDate = licenseUsageGetUsageParams.startDate + additionalHeaders = licenseUsageGetUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseUsageGetUsageParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional>) = groupBy(groupBy.getOrNull()) + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseUsageGetUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseUsageGetUsageParams = + LicenseUsageGetUsageParams( + licenseId, + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetUsageParams && + licenseId == other.licenseId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + licenseId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseUsageGetUsageParams{licenseId=$licenseId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt new file mode 100644 index 000000000..b97547df0 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt @@ -0,0 +1,959 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseUsageGetUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException 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 paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @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 [LicenseUsageGetUsageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseUsageGetUsageResponse: LicenseUsageGetUsageResponse) = apply { + data = licenseUsageGetUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseUsageGetUsageResponse.paginationMetadata + additionalProperties = licenseUsageGetUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + 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 [LicenseUsageGetUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseUsageGetUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the period. + * + * @throws OrbInvalidDataException 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 allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the period. + * + * @throws OrbInvalidDataException 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 consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage period. + * + * @throws OrbInvalidDataException 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 endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException 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 pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException 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 remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage period. + * + * @throws OrbInvalidDataException 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 startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException 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 subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Optional = + allocationEligibleCredits.getOptional("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): Optional = + externalLicenseId.getOptional("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): Optional = licenseId.getOptional("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Optional = + sharedPoolCredits.getOptional("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @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 [Data]. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Alias for calling [Builder.allocationEligibleCredits] with + * `allocationEligibleCredits.orElse(null)`. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Optional) = + allocationEligibleCredits(allocationEligibleCredits.getOrNull()) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. + */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Alias for calling [Builder.sharedPoolCredits] with `sharedPoolCredits.orElse(null)`. + */ + fun sharedPoolCredits(sharedPoolCredits: Optional) = + sharedPoolCredits(sharedPoolCredits.getOrNull()) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocatedCredits.asKnown().isPresent) 1 else 0) + + (if (consumedCredits.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (pricingUnit.asKnown().isPresent) 1 else 0) + + (if (remainingCredits.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (allocationEligibleCredits.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseId.asKnown().isPresent) 1 else 0) + + (if (sharedPoolCredits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseUsageGetUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt index f2b06e1c5..5c520c742 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt @@ -30,6 +30,7 @@ private constructor( private val expiresAtEndOfCadence: JsonField, private val filters: JsonField>, private val itemId: JsonField, + private val licenseTypeId: JsonField, private val perUnitCostBasis: JsonField, private val additionalProperties: MutableMap, ) { @@ -49,6 +50,9 @@ private constructor( @ExcludeMissing filters: JsonField> = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -60,6 +64,7 @@ private constructor( expiresAtEndOfCadence, filters, itemId, + licenseTypeId, perUnitCostBasis, mutableMapOf(), ) @@ -125,6 +130,14 @@ private constructor( */ fun itemId(): Optional = itemId.getOptional("item_id") + /** + * The license type ID to associate the price with license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced * according to the quantity and per unit cost basis specified for the allocation each cadence. @@ -189,6 +202,15 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -236,6 +258,7 @@ private constructor( private var expiresAtEndOfCadence: JsonField = JsonMissing.of() private var filters: JsonField>? = null private var itemId: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var perUnitCostBasis: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -248,6 +271,7 @@ private constructor( expiresAtEndOfCadence = newAllocationPrice.expiresAtEndOfCadence filters = newAllocationPrice.filters.map { it.toMutableList() } itemId = newAllocationPrice.itemId + licenseTypeId = newAllocationPrice.licenseTypeId perUnitCostBasis = newAllocationPrice.perUnitCostBasis additionalProperties = newAllocationPrice.additionalProperties.toMutableMap() } @@ -387,6 +411,25 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The license type ID to associate the price with license allocation. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced * according to the quantity and per unit cost basis specified for the allocation each @@ -448,6 +491,7 @@ private constructor( expiresAtEndOfCadence, (filters ?: JsonMissing.of()).map { it.toImmutable() }, itemId, + licenseTypeId, perUnitCostBasis, additionalProperties.toMutableMap(), ) @@ -467,6 +511,7 @@ private constructor( expiresAtEndOfCadence() filters().ifPresent { it.forEach { it.validate() } } itemId() + licenseTypeId() perUnitCostBasis() validated = true } @@ -493,6 +538,7 @@ private constructor( (if (expiresAtEndOfCadence.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) /** The cadence at which to allocate the amount to the customer. */ @@ -1158,6 +1204,7 @@ private constructor( expiresAtEndOfCadence == other.expiresAtEndOfCadence && filters == other.filters && itemId == other.itemId && + licenseTypeId == other.licenseTypeId && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties } @@ -1171,6 +1218,7 @@ private constructor( expiresAtEndOfCadence, filters, itemId, + licenseTypeId, perUnitCostBasis, additionalProperties, ) @@ -1179,5 +1227,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, itemId=$itemId, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, itemId=$itemId, licenseTypeId=$licenseTypeId, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt index 1aaa47b7c..05d215672 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( bulkConfig, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingBulkPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingBulkPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingBulkPrice.licenseTypeId metadata = newFloatingBulkPrice.metadata additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() } @@ -832,6 +856,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -905,6 +948,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -933,6 +977,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -968,6 +1013,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1366,6 +1412,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1388,6 +1435,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1396,5 +1444,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt index 2f1da6385..ff28636db 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( bulkWithProrationConfig, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -485,6 +508,7 @@ private constructor( invoiceGroupingKey = newFloatingBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingBulkWithProrationPrice.licenseTypeId metadata = newFloatingBulkWithProrationPrice.metadata additionalProperties = newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() @@ -845,6 +869,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -918,6 +961,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -946,6 +990,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -981,6 +1026,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_proration pricing */ @@ -1779,6 +1825,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1801,6 +1848,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1809,5 +1857,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt index 403783eed..1e42779c2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingCumulativeGroupedBulkPrice.licenseTypeId metadata = newFloatingCumulativeGroupedBulkPrice.metadata additionalProperties = newFloatingCumulativeGroupedBulkPrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -948,6 +992,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1028,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1869,6 +1915,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1891,6 +1938,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1899,5 +1947,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt index a508400bb..a0a3185d9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -399,6 +412,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedAllocationPrice.licenseTypeId metadata = newFloatingGroupedAllocationPrice.metadata additionalProperties = newFloatingGroupedAllocationPrice.additionalProperties.toMutableMap() @@ -844,6 +868,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -917,6 +960,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -945,6 +989,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -980,6 +1025,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1634,6 +1680,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1656,6 +1703,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1664,5 +1712,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt index e1cd91b42..277c98efb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedTieredPackagePrice.licenseTypeId metadata = newFloatingGroupedTieredPackagePrice.metadata additionalProperties = newFloatingGroupedTieredPackagePrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -948,6 +992,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1028,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1861,6 +1907,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1883,6 +1930,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1891,5 +1939,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt index c9dc4809a..eee909059 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -482,6 +505,7 @@ private constructor( fixedPriceQuantity = newFloatingGroupedTieredPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedTieredPrice.licenseTypeId metadata = newFloatingGroupedTieredPrice.metadata additionalProperties = newFloatingGroupedTieredPrice.additionalProperties.toMutableMap() } @@ -840,6 +864,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -913,6 +956,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -941,6 +985,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -976,6 +1021,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1813,6 +1859,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1835,6 +1882,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1843,5 +1891,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt index c674d7b0b..92b34cab4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -402,6 +415,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -463,6 +485,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -490,6 +513,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newFloatingGroupedWithMeteredMinimumPrice.metadata additionalProperties = newFloatingGroupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() @@ -850,6 +874,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -923,6 +966,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -951,6 +995,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -986,6 +1031,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -2252,6 +2298,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -2274,6 +2321,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -2282,5 +2330,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt index d22b0af45..54b46cba4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -462,6 +484,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -489,6 +512,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedWithProratedMinimumPrice.licenseTypeId metadata = newFloatingGroupedWithProratedMinimumPrice.metadata additionalProperties = newFloatingGroupedWithProratedMinimumPrice.additionalProperties.toMutableMap() @@ -849,6 +873,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -922,6 +965,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -950,6 +994,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -985,6 +1030,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1632,6 +1678,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1654,6 +1701,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1662,5 +1710,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt index f0792977e..553d63679 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixPrice.licenseTypeId metadata = newFloatingMatrixPrice.metadata additionalProperties = newFloatingMatrixPrice.additionalProperties.toMutableMap() } @@ -834,6 +858,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -907,6 +950,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -935,6 +979,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -970,6 +1015,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1368,6 +1414,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1390,6 +1437,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1398,5 +1446,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt index 0038970cc..0445d01d7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -487,6 +510,7 @@ private constructor( invoiceGroupingKey = newFloatingMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixWithAllocationPrice.licenseTypeId metadata = newFloatingMatrixWithAllocationPrice.metadata additionalProperties = newFloatingMatrixWithAllocationPrice.additionalProperties.toMutableMap() @@ -846,6 +870,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -919,6 +962,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -947,6 +991,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -982,6 +1027,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1380,6 +1426,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1402,6 +1449,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1410,5 +1458,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt index 027156aab..55ddec8af 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixWithDisplayNamePrice.licenseTypeId metadata = newFloatingMatrixWithDisplayNamePrice.metadata additionalProperties = newFloatingMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -948,6 +992,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1028,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1870,6 +1916,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1892,6 +1939,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1900,5 +1948,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt index 3cfa1d538..473a74a12 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMaxGroupTieredPackagePrice.licenseTypeId metadata = newFloatingMaxGroupTieredPackagePrice.metadata additionalProperties = newFloatingMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -948,6 +992,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1028,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1862,6 +1908,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1884,6 +1931,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1892,5 +1940,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt index 4ed974d20..43c8038a8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -399,6 +412,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMinimumCompositePrice.licenseTypeId metadata = newFloatingMinimumCompositePrice.metadata additionalProperties = newFloatingMinimumCompositePrice.additionalProperties.toMutableMap() @@ -844,6 +868,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -917,6 +960,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -945,6 +989,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -980,6 +1025,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1586,6 +1632,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1608,6 +1655,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1616,5 +1664,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMinimumCompositePrice{cadence=$cadence, currency=$currency, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMinimumCompositePrice{cadence=$cadence, currency=$currency, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt index fb230bd52..20c2bd01d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingPackagePrice.licenseTypeId metadata = newFloatingPackagePrice.metadata additionalProperties = newFloatingPackagePrice.additionalProperties.toMutableMap() } @@ -834,6 +858,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -907,6 +950,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -935,6 +979,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -970,6 +1015,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1368,6 +1414,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1390,6 +1437,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1398,5 +1446,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt index f14ba65cf..b36be7b1a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -487,6 +510,7 @@ private constructor( invoiceGroupingKey = newFloatingPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingPackageWithAllocationPrice.licenseTypeId metadata = newFloatingPackageWithAllocationPrice.metadata additionalProperties = newFloatingPackageWithAllocationPrice.additionalProperties.toMutableMap() @@ -846,6 +870,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -919,6 +962,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -947,6 +991,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -982,6 +1027,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1628,6 +1674,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1650,6 +1697,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1658,5 +1706,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt index 3f49c742f..14a85c6f9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt @@ -40,6 +40,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -405,6 +418,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -467,6 +489,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -497,6 +520,7 @@ private constructor( invoiceGroupingKey = newFloatingScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newFloatingScalableMatrixWithTieredPricingPrice.metadata additionalProperties = newFloatingScalableMatrixWithTieredPricingPrice.additionalProperties.toMutableMap() @@ -862,6 +886,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -938,6 +981,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -966,6 +1010,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -1001,6 +1046,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -2226,6 +2272,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -2248,6 +2295,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -2256,5 +2304,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 288ff9601..1b34c0d0b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -402,6 +415,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -464,6 +486,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -493,6 +516,7 @@ private constructor( invoiceGroupingKey = newFloatingScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newFloatingScalableMatrixWithUnitPricingPrice.metadata additionalProperties = newFloatingScalableMatrixWithUnitPricingPrice.additionalProperties.toMutableMap() @@ -853,6 +877,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -929,6 +972,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -957,6 +1001,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -992,6 +1037,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1272,6 +1318,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1288,6 +1335,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1296,6 +1346,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1326,6 +1377,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1369,6 +1428,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1420,6 +1488,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1434,6 +1503,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1495,6 +1565,23 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1576,6 +1663,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1592,6 +1680,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1616,6 +1705,7 @@ private constructor( (if (firstDimension.asKnown().isPresent) 1 else 0) + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (prorate.asKnown().isPresent) 1 else 0) + (if (secondDimension.asKnown().isPresent) 1 else 0) @@ -1898,6 +1988,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1908,6 +1999,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1917,7 +2009,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -2046,6 +2138,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -2068,6 +2161,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -2076,5 +2170,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt index 5d4817829..21a2952b5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingThresholdTotalAmountPrice.licenseTypeId metadata = newFloatingThresholdTotalAmountPrice.metadata additionalProperties = newFloatingThresholdTotalAmountPrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -948,6 +992,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1028,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1833,6 +1879,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1855,6 +1902,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1863,5 +1911,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index 2e0f9bb42..96d56f9e7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -482,6 +505,7 @@ private constructor( fixedPriceQuantity = newFloatingTieredPackagePrice.fixedPriceQuantity invoiceGroupingKey = newFloatingTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPackagePrice.licenseTypeId metadata = newFloatingTieredPackagePrice.metadata additionalProperties = newFloatingTieredPackagePrice.additionalProperties.toMutableMap() } @@ -840,6 +864,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -913,6 +956,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -941,6 +985,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -976,6 +1021,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1811,6 +1857,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1833,6 +1880,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1841,5 +1889,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt index df8245039..4990f81b0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -402,6 +415,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -463,6 +485,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -490,6 +513,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPackageWithMinimumPrice.licenseTypeId metadata = newFloatingTieredPackageWithMinimumPrice.metadata additionalProperties = newFloatingTieredPackageWithMinimumPrice.additionalProperties.toMutableMap() @@ -850,6 +874,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -923,6 +966,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -951,6 +995,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -986,6 +1031,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1860,6 +1906,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1882,6 +1929,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1890,5 +1938,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt index 803a833a7..002d841ef 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingTieredPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPrice.licenseTypeId metadata = newFloatingTieredPrice.metadata additionalProperties = newFloatingTieredPrice.additionalProperties.toMutableMap() } @@ -834,6 +858,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -907,6 +950,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -935,6 +979,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -970,6 +1015,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1368,6 +1414,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1390,6 +1437,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1398,5 +1446,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt index c8f1fe5b4..ee5ccfbad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -485,6 +508,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredWithMinimumPrice.licenseTypeId metadata = newFloatingTieredWithMinimumPrice.metadata additionalProperties = newFloatingTieredWithMinimumPrice.additionalProperties.toMutableMap() @@ -845,6 +869,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -918,6 +961,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -946,6 +990,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -981,6 +1026,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1901,6 +1947,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1923,6 +1970,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1931,5 +1979,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt index bb9ebf2a4..71e4249fb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredWithProrationPrice.licenseTypeId metadata = newFloatingTieredWithProrationPrice.metadata additionalProperties = newFloatingTieredWithProrationPrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -948,6 +992,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1028,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1782,6 +1828,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1804,6 +1851,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1812,5 +1860,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt index 75607f1db..b29348278 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingUnitPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitPrice.licenseTypeId metadata = newFloatingUnitPrice.metadata additionalProperties = newFloatingUnitPrice.additionalProperties.toMutableMap() } @@ -832,6 +856,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -905,6 +948,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -933,6 +977,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -968,6 +1013,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1366,6 +1412,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1388,6 +1435,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1396,5 +1444,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt index 4a85f81d1..af7e17d34 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -399,6 +412,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitWithPercentPrice.licenseTypeId metadata = newFloatingUnitWithPercentPrice.metadata additionalProperties = newFloatingUnitWithPercentPrice.additionalProperties.toMutableMap() @@ -843,6 +867,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -916,6 +959,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -944,6 +988,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -979,6 +1024,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1582,6 +1628,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1604,6 +1651,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1612,5 +1660,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt index a46c6e1d9..fcf2202af 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -399,6 +412,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitWithProrationPrice.licenseTypeId metadata = newFloatingUnitWithProrationPrice.metadata additionalProperties = newFloatingUnitWithProrationPrice.additionalProperties.toMutableMap() @@ -844,6 +868,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -917,6 +960,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -945,6 +989,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -980,6 +1025,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1542,6 +1588,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1564,6 +1611,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1572,5 +1620,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt index 8960972a1..83d81cc78 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanBulkPrice.fixedPriceQuantity invoiceGroupingKey = newPlanBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanBulkPrice.invoicingCycleConfiguration + licenseTypeId = newPlanBulkPrice.licenseTypeId metadata = newPlanBulkPrice.metadata referenceId = newPlanBulkPrice.referenceId additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() @@ -863,6 +887,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -953,6 +996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -982,6 +1026,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1018,6 +1063,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1417,6 +1463,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1440,6 +1487,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1449,5 +1497,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt index bebc0f4b7..110d54a55 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( fixedPriceQuantity = newPlanBulkWithProrationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanBulkWithProrationPrice.licenseTypeId metadata = newPlanBulkWithProrationPrice.metadata referenceId = newPlanBulkWithProrationPrice.referenceId additionalProperties = newPlanBulkWithProrationPrice.additionalProperties.toMutableMap() @@ -872,6 +896,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -962,6 +1005,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -991,6 +1035,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1027,6 +1072,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1826,6 +1872,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1849,6 +1896,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1858,5 +1906,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt index 2c6298670..2b8fcce28 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newPlanCumulativeGroupedBulkPrice.licenseTypeId metadata = newPlanCumulativeGroupedBulkPrice.metadata referenceId = newPlanCumulativeGroupedBulkPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1919,6 +1965,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1942,6 +1989,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1951,5 +1999,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt index 5038dd58b..426100a29 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -505,6 +528,7 @@ private constructor( fixedPriceQuantity = newPlanGroupedAllocationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedAllocationPrice.licenseTypeId metadata = newPlanGroupedAllocationPrice.metadata referenceId = newPlanGroupedAllocationPrice.referenceId additionalProperties = newPlanGroupedAllocationPrice.additionalProperties.toMutableMap() @@ -871,6 +895,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -961,6 +1004,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -990,6 +1034,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1026,6 +1071,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1681,6 +1727,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1704,6 +1751,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1713,5 +1761,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt index eff28004e..04476c22a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedTieredPackagePrice.licenseTypeId metadata = newPlanGroupedTieredPackagePrice.metadata referenceId = newPlanGroupedTieredPackagePrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1911,6 +1957,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1934,6 +1981,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1943,5 +1991,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt index 908dc8d42..2e76b8bdf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( fixedPriceQuantity = newPlanGroupedTieredPrice.fixedPriceQuantity invoiceGroupingKey = newPlanGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedTieredPrice.licenseTypeId metadata = newPlanGroupedTieredPrice.metadata referenceId = newPlanGroupedTieredPrice.referenceId additionalProperties = newPlanGroupedTieredPrice.additionalProperties.toMutableMap() @@ -869,6 +893,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -959,6 +1002,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -988,6 +1032,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1024,6 +1069,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1862,6 +1908,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1885,6 +1932,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1894,5 +1942,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt index 0c06163b4..37bb160d0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -514,6 +537,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newPlanGroupedWithMeteredMinimumPrice.metadata referenceId = newPlanGroupedWithMeteredMinimumPrice.referenceId additionalProperties = @@ -881,6 +905,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -971,6 +1014,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1000,6 +1044,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1036,6 +1081,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -2303,6 +2349,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2326,6 +2373,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2335,5 +2383,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt index cc44542c7..8edfc0499 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -485,6 +507,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -513,6 +536,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedWithProratedMinimumPrice.licenseTypeId metadata = newPlanGroupedWithProratedMinimumPrice.metadata referenceId = newPlanGroupedWithProratedMinimumPrice.referenceId additionalProperties = @@ -880,6 +904,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -970,6 +1013,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -999,6 +1043,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1035,6 +1080,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1683,6 +1729,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1706,6 +1753,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1715,5 +1763,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt index 1fdfa4ccb..034a9fc5d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newPlanMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixPrice.licenseTypeId metadata = newPlanMatrixPrice.metadata referenceId = newPlanMatrixPrice.referenceId additionalProperties = newPlanMatrixPrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -984,6 +1028,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1065,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1419,6 +1465,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1489,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1499,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt index c501222cb..0ee980dc4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newPlanMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixWithAllocationPrice.licenseTypeId metadata = newPlanMatrixWithAllocationPrice.metadata referenceId = newPlanMatrixWithAllocationPrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -995,6 +1039,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1076,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1430,6 +1476,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1453,6 +1500,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1462,5 +1510,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt index 3d27388c6..94efb23da 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixWithDisplayNamePrice.licenseTypeId metadata = newPlanMatrixWithDisplayNamePrice.metadata referenceId = newPlanMatrixWithDisplayNamePrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1920,6 +1966,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1943,6 +1990,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1952,5 +2000,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt index d213396f0..ffda2eceb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMaxGroupTieredPackagePrice.licenseTypeId metadata = newPlanMaxGroupTieredPackagePrice.metadata referenceId = newPlanMaxGroupTieredPackagePrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1912,6 +1958,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1935,6 +1982,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1944,5 +1992,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt index 0ec463b42..9a9012bcd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -481,6 +503,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( fixedPriceQuantity = newPlanMinimumCompositePrice.fixedPriceQuantity invoiceGroupingKey = newPlanMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMinimumCompositePrice.licenseTypeId metadata = newPlanMinimumCompositePrice.metadata referenceId = newPlanMinimumCompositePrice.referenceId additionalProperties = newPlanMinimumCompositePrice.additionalProperties.toMutableMap() @@ -870,6 +894,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -960,6 +1003,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -989,6 +1033,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1025,6 +1070,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1632,6 +1678,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1655,6 +1702,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1664,5 +1712,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt index 2ba731b67..bb684ddf2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanPackagePrice.fixedPriceQuantity invoiceGroupingKey = newPlanPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanPackagePrice.licenseTypeId metadata = newPlanPackagePrice.metadata referenceId = newPlanPackagePrice.referenceId additionalProperties = newPlanPackagePrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -984,6 +1028,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1065,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1419,6 +1465,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1489,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1499,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt index 432d40e9a..2353c370f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newPlanPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanPackageWithAllocationPrice.licenseTypeId metadata = newPlanPackageWithAllocationPrice.metadata referenceId = newPlanPackageWithAllocationPrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -995,6 +1039,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1076,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1678,6 +1724,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1701,6 +1748,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1710,5 +1758,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt index a2e27e4e8..54d9dbf77 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt @@ -40,6 +40,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -89,6 +90,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -110,6 +114,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -255,6 +260,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -420,6 +433,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -490,6 +512,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -518,6 +541,7 @@ private constructor( invoiceGroupingKey = newPlanScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newPlanScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newPlanScalableMatrixWithTieredPricingPrice.metadata referenceId = newPlanScalableMatrixWithTieredPricingPrice.referenceId additionalProperties = @@ -890,6 +914,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -983,6 +1026,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1012,6 +1056,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1048,6 +1093,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -2274,6 +2320,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2297,6 +2344,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2306,5 +2354,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index 13e0e76c5..bba3544ef 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -487,6 +509,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -515,6 +538,7 @@ private constructor( invoiceGroupingKey = newPlanScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newPlanScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newPlanScalableMatrixWithUnitPricingPrice.metadata referenceId = newPlanScalableMatrixWithUnitPricingPrice.referenceId additionalProperties = @@ -882,6 +906,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -975,6 +1018,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1004,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1040,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1321,6 +1367,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1337,6 +1384,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1345,6 +1395,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1375,6 +1426,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1418,6 +1477,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1469,6 +1537,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1483,6 +1552,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1544,6 +1614,23 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1625,6 +1712,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1641,6 +1729,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1665,6 +1754,7 @@ private constructor( (if (firstDimension.asKnown().isPresent) 1 else 0) + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (prorate.asKnown().isPresent) 1 else 0) + (if (secondDimension.asKnown().isPresent) 1 else 0) @@ -1947,6 +2037,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1957,6 +2048,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1966,7 +2058,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -2095,6 +2187,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2118,6 +2211,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2127,5 +2221,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt index 77f2b25ac..30325af84 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newPlanThresholdTotalAmountPrice.licenseTypeId metadata = newPlanThresholdTotalAmountPrice.metadata referenceId = newPlanThresholdTotalAmountPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1883,6 +1929,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1906,6 +1953,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1915,5 +1963,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index 2b4b54067..f3e5e6001 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( fixedPriceQuantity = newPlanTieredPackagePrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPackagePrice.licenseTypeId metadata = newPlanTieredPackagePrice.metadata referenceId = newPlanTieredPackagePrice.referenceId additionalProperties = newPlanTieredPackagePrice.additionalProperties.toMutableMap() @@ -869,6 +893,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -959,6 +1002,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -988,6 +1032,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1024,6 +1069,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1860,6 +1906,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1883,6 +1930,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1892,5 +1940,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt index bdc83bf3a..519e990e2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -514,6 +537,7 @@ private constructor( invoiceGroupingKey = newPlanTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPackageWithMinimumPrice.licenseTypeId metadata = newPlanTieredPackageWithMinimumPrice.metadata referenceId = newPlanTieredPackageWithMinimumPrice.referenceId additionalProperties = @@ -881,6 +905,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -971,6 +1014,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1000,6 +1044,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1036,6 +1081,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1911,6 +1957,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1934,6 +1981,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1943,5 +1991,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt index 38bf989d4..9ca434132 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanTieredPrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPrice.licenseTypeId metadata = newPlanTieredPrice.metadata referenceId = newPlanTieredPrice.referenceId additionalProperties = newPlanTieredPrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -984,6 +1028,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1065,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1419,6 +1465,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1489,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1499,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt index 299ef06bf..d21c15292 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( fixedPriceQuantity = newPlanTieredWithMinimumPrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredWithMinimumPrice.licenseTypeId metadata = newPlanTieredWithMinimumPrice.metadata referenceId = newPlanTieredWithMinimumPrice.referenceId additionalProperties = newPlanTieredWithMinimumPrice.additionalProperties.toMutableMap() @@ -872,6 +896,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -962,6 +1005,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -991,6 +1035,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1027,6 +1072,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1948,6 +1994,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1971,6 +2018,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1980,5 +2028,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt index 5dcd3e753..3c1590593 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanUnitPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitPrice.licenseTypeId metadata = newPlanUnitPrice.metadata referenceId = newPlanUnitPrice.referenceId additionalProperties = newPlanUnitPrice.additionalProperties.toMutableMap() @@ -863,6 +887,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -953,6 +996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -982,6 +1026,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1018,6 +1063,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1417,6 +1463,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1440,6 +1487,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1449,5 +1497,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt index 2070811bc..a816e1e5b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -481,6 +503,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( fixedPriceQuantity = newPlanUnitWithPercentPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitWithPercentPrice.licenseTypeId metadata = newPlanUnitWithPercentPrice.metadata referenceId = newPlanUnitWithPercentPrice.referenceId additionalProperties = newPlanUnitWithPercentPrice.additionalProperties.toMutableMap() @@ -869,6 +893,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -959,6 +1002,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -988,6 +1032,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1024,6 +1069,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1628,6 +1674,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1651,6 +1698,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1660,5 +1708,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt index 47b377682..fb71b81d9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -505,6 +528,7 @@ private constructor( fixedPriceQuantity = newPlanUnitWithProrationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitWithProrationPrice.licenseTypeId metadata = newPlanUnitWithProrationPrice.metadata referenceId = newPlanUnitWithProrationPrice.referenceId additionalProperties = newPlanUnitWithProrationPrice.additionalProperties.toMutableMap() @@ -871,6 +895,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -961,6 +1004,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -990,6 +1034,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1026,6 +1071,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1589,6 +1635,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1612,6 +1659,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1621,5 +1669,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt index b10d26b6b..b877b8a5e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionBulkPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionBulkPrice.licenseTypeId metadata = newSubscriptionBulkPrice.metadata referenceId = newSubscriptionBulkPrice.referenceId additionalProperties = newSubscriptionBulkPrice.additionalProperties.toMutableMap() @@ -863,6 +887,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -953,6 +996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -982,6 +1026,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1018,6 +1063,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1417,6 +1463,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1440,6 +1487,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1449,5 +1497,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt index 7ce89bc09..3ca82cf7a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newSubscriptionBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionBulkWithProrationPrice.licenseTypeId metadata = newSubscriptionBulkWithProrationPrice.metadata referenceId = newSubscriptionBulkWithProrationPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1831,6 +1877,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1854,6 +1901,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1863,5 +1911,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt index 0714087d9..e9cab7bc0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionCumulativeGroupedBulkPrice.licenseTypeId metadata = newSubscriptionCumulativeGroupedBulkPrice.metadata referenceId = newSubscriptionCumulativeGroupedBulkPrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -997,6 +1041,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1078,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1920,6 +1966,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1943,6 +1990,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1952,5 +2000,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt index 40d24c3aa..ce144b1a4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedAllocationPrice.licenseTypeId metadata = newSubscriptionGroupedAllocationPrice.metadata referenceId = newSubscriptionGroupedAllocationPrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -995,6 +1039,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1076,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1686,6 +1732,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1709,6 +1756,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1718,5 +1766,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt index f5474be24..6786c525e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedTieredPackagePrice.licenseTypeId metadata = newSubscriptionGroupedTieredPackagePrice.metadata referenceId = newSubscriptionGroupedTieredPackagePrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -997,6 +1041,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1078,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1912,6 +1958,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1935,6 +1982,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1944,5 +1992,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt index 69f5529b7..8e745368f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedTieredPrice.licenseTypeId metadata = newSubscriptionGroupedTieredPrice.metadata referenceId = newSubscriptionGroupedTieredPrice.referenceId additionalProperties = @@ -875,6 +899,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -965,6 +1008,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -994,6 +1038,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1030,6 +1075,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1868,6 +1914,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1891,6 +1938,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1900,5 +1948,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt index 065e8f678..d7e6c1664 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -516,6 +539,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newSubscriptionGroupedWithMeteredMinimumPrice.metadata referenceId = newSubscriptionGroupedWithMeteredMinimumPrice.referenceId additionalProperties = @@ -883,6 +907,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -973,6 +1016,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1002,6 +1046,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1038,6 +1083,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -2305,6 +2351,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2328,6 +2375,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2337,5 +2385,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt index 477c3494b..ad6146e66 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -485,6 +507,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -515,6 +538,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedWithProratedMinimumPrice.licenseTypeId metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId additionalProperties = @@ -882,6 +906,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -972,6 +1015,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1001,6 +1045,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1037,6 +1082,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1685,6 +1731,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1708,6 +1755,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1717,5 +1765,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt index eb63bedb1..356f8db1f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixPrice.licenseTypeId metadata = newSubscriptionMatrixPrice.metadata referenceId = newSubscriptionMatrixPrice.referenceId additionalProperties = newSubscriptionMatrixPrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -984,6 +1028,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1065,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1419,6 +1465,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1489,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1499,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt index 1b57eceb5..e5ea755c1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixWithAllocationPrice.licenseTypeId metadata = newSubscriptionMatrixWithAllocationPrice.metadata referenceId = newSubscriptionMatrixWithAllocationPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1431,6 +1477,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1454,6 +1501,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1463,5 +1511,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt index 17fb78a46..93f226805 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixWithDisplayNamePrice.licenseTypeId metadata = newSubscriptionMatrixWithDisplayNamePrice.metadata referenceId = newSubscriptionMatrixWithDisplayNamePrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -997,6 +1041,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1078,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1921,6 +1967,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1944,6 +1991,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1953,5 +2001,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt index cc8472998..4b874f38d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMaxGroupTieredPackagePrice.licenseTypeId metadata = newSubscriptionMaxGroupTieredPackagePrice.metadata referenceId = newSubscriptionMaxGroupTieredPackagePrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -997,6 +1041,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1078,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1913,6 +1959,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1936,6 +1983,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1945,5 +1993,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt index 0ea7c4a45..dd7c80b30 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMinimumCompositePrice.licenseTypeId metadata = newSubscriptionMinimumCompositePrice.metadata referenceId = newSubscriptionMinimumCompositePrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -995,6 +1039,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1076,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1638,6 +1684,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1661,6 +1708,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1670,5 +1718,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt index 421584a46..688cb675b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -502,6 +525,7 @@ private constructor( fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionPackagePrice.licenseTypeId metadata = newSubscriptionPackagePrice.metadata referenceId = newSubscriptionPackagePrice.referenceId additionalProperties = newSubscriptionPackagePrice.additionalProperties.toMutableMap() @@ -866,6 +890,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -956,6 +999,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -985,6 +1029,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1021,6 +1066,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1420,6 +1466,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1443,6 +1490,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1452,5 +1500,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt index a61347544..1987a942a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionPackageWithAllocationPrice.licenseTypeId metadata = newSubscriptionPackageWithAllocationPrice.metadata referenceId = newSubscriptionPackageWithAllocationPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1679,6 +1725,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1702,6 +1749,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1711,5 +1759,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt index e6c9a0281..c0a452ab3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt @@ -40,6 +40,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -89,6 +90,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -110,6 +114,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -255,6 +260,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -420,6 +433,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -490,6 +512,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -523,6 +546,7 @@ private constructor( newSubscriptionScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newSubscriptionScalableMatrixWithTieredPricingPrice.metadata referenceId = newSubscriptionScalableMatrixWithTieredPricingPrice.referenceId additionalProperties = @@ -896,6 +920,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -989,6 +1032,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1018,6 +1062,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1054,6 +1099,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -2280,6 +2326,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2303,6 +2350,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2312,5 +2360,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index dc6e01f4f..c0b4c0fa4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -487,6 +509,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -520,6 +543,7 @@ private constructor( newSubscriptionScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newSubscriptionScalableMatrixWithUnitPricingPrice.metadata referenceId = newSubscriptionScalableMatrixWithUnitPricingPrice.referenceId additionalProperties = @@ -888,6 +912,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -981,6 +1024,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1010,6 +1054,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1046,6 +1091,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1327,6 +1373,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1343,6 +1390,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1351,6 +1401,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1381,6 +1432,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1424,6 +1483,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1475,6 +1543,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1489,6 +1558,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1550,6 +1620,23 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1631,6 +1718,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1647,6 +1735,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1671,6 +1760,7 @@ private constructor( (if (firstDimension.asKnown().isPresent) 1 else 0) + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (prorate.asKnown().isPresent) 1 else 0) + (if (secondDimension.asKnown().isPresent) 1 else 0) @@ -1953,6 +2043,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1963,6 +2054,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1972,7 +2064,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -2101,6 +2193,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2124,6 +2217,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2133,5 +2227,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt index e1b30a7fc..cf471158b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionThresholdTotalAmountPrice.licenseTypeId metadata = newSubscriptionThresholdTotalAmountPrice.metadata referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -997,6 +1041,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1078,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1884,6 +1930,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1907,6 +1954,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1916,5 +1964,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index 5c3968092..eb608b0b3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPackagePrice.licenseTypeId metadata = newSubscriptionTieredPackagePrice.metadata referenceId = newSubscriptionTieredPackagePrice.referenceId additionalProperties = @@ -875,6 +899,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -965,6 +1008,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -994,6 +1038,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1030,6 +1075,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1866,6 +1912,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1889,6 +1936,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1898,5 +1946,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt index 9036a3f93..a27ad027f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -515,6 +538,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPackageWithMinimumPrice.licenseTypeId metadata = newSubscriptionTieredPackageWithMinimumPrice.metadata referenceId = newSubscriptionTieredPackageWithMinimumPrice.referenceId additionalProperties = @@ -882,6 +906,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -972,6 +1015,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -1001,6 +1045,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1037,6 +1082,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1912,6 +1958,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1935,6 +1982,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1944,5 +1992,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt index 79610bbce..56119fb58 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPrice.licenseTypeId metadata = newSubscriptionTieredPrice.metadata referenceId = newSubscriptionTieredPrice.referenceId additionalProperties = newSubscriptionTieredPrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -984,6 +1028,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1065,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1419,6 +1465,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1489,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1499,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt index ec6a48bdb..221a7a3a6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredWithMinimumPrice.licenseTypeId metadata = newSubscriptionTieredWithMinimumPrice.metadata referenceId = newSubscriptionTieredWithMinimumPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -996,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1953,6 +1999,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1976,6 +2023,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1985,5 +2033,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt index 4d209d5f6..efc051922 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitPrice.licenseTypeId metadata = newSubscriptionUnitPrice.metadata referenceId = newSubscriptionUnitPrice.referenceId additionalProperties = newSubscriptionUnitPrice.additionalProperties.toMutableMap() @@ -863,6 +887,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -953,6 +996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -982,6 +1026,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1018,6 +1063,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1417,6 +1463,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1440,6 +1487,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1449,5 +1497,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt index fb86e9e26..9a12bdbfd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitWithPercentPrice.licenseTypeId metadata = newSubscriptionUnitWithPercentPrice.metadata referenceId = newSubscriptionUnitWithPercentPrice.referenceId additionalProperties = @@ -875,6 +899,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -965,6 +1008,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -994,6 +1038,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1030,6 +1075,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1634,6 +1680,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1657,6 +1704,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1666,5 +1714,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt index f41dd44b1..ceca63908 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitWithProrationPrice.licenseTypeId metadata = newSubscriptionUnitWithProrationPrice.metadata referenceId = newSubscriptionUnitWithProrationPrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -995,6 +1039,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1076,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1594,6 +1640,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1617,6 +1664,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1626,5 +1674,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index 83f76051e..e3aa7288d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -1220,6 +1220,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1230,11 +1231,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1245,6 +1249,15 @@ private constructor( fun allocationPrice(): Optional = allocationPrice.getOptional("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + /** * The phase to add this price to. * @@ -1271,6 +1284,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1310,6 +1333,7 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1317,6 +1341,7 @@ private constructor( @JvmSynthetic internal fun from(price: Price) = apply { allocationPrice = price.allocationPrice + licenseAllocationPrice = price.licenseAllocationPrice planPhaseOrder = price.planPhaseOrder this.price = price.price additionalProperties = price.additionalProperties.toMutableMap() @@ -1341,6 +1366,331 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnit(unit)`. + */ + fun licenseAllocationPrice(unit: LicenseAllocationPrice.Unit) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnit(unit)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTiered(tiered)`. + */ + fun licenseAllocationPrice(tiered: LicenseAllocationPrice.Tiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofTiered(tiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulk(bulk)`. + */ + fun licenseAllocationPrice(bulk: LicenseAllocationPrice.Bulk) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulk(bulk)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)`. + */ + fun licenseAllocationPrice(bulkWithFilters: LicenseAllocationPrice.BulkWithFilters) = + licenseAllocationPrice(LicenseAllocationPrice.ofBulkWithFilters(bulkWithFilters)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackage(package_)`. + */ + fun licenseAllocationPrice(package_: LicenseAllocationPrice.Package) = + licenseAllocationPrice(LicenseAllocationPrice.ofPackage(package_)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrix(matrix)`. + */ + fun licenseAllocationPrice(matrix: LicenseAllocationPrice.Matrix) = + licenseAllocationPrice(LicenseAllocationPrice.ofMatrix(matrix)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun licenseAllocationPrice( + thresholdTotalAmount: LicenseAllocationPrice.ThresholdTotalAmount + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofThresholdTotalAmount(thresholdTotalAmount) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackage(tieredPackage)`. + */ + fun licenseAllocationPrice(tieredPackage: LicenseAllocationPrice.TieredPackage) = + licenseAllocationPrice(LicenseAllocationPrice.ofTieredPackage(tieredPackage)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredWithMinimum: LicenseAllocationPrice.TieredWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithMinimum(tieredWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTiered(groupedTiered)`. + */ + fun licenseAllocationPrice(groupedTiered: LicenseAllocationPrice.GroupedTiered) = + licenseAllocationPrice(LicenseAllocationPrice.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun licenseAllocationPrice( + tieredPackageWithMinimum: LicenseAllocationPrice.TieredPackageWithMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredPackageWithMinimum(tieredPackageWithMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun licenseAllocationPrice( + packageWithAllocation: LicenseAllocationPrice.PackageWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofPackageWithAllocation(packageWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)`. + */ + fun licenseAllocationPrice(unitWithPercent: LicenseAllocationPrice.UnitWithPercent) = + licenseAllocationPrice(LicenseAllocationPrice.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun licenseAllocationPrice( + matrixWithAllocation: LicenseAllocationPrice.MatrixWithAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithAllocation(matrixWithAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofTieredWithProration(tieredWithProration)`. + */ + fun licenseAllocationPrice( + tieredWithProration: LicenseAllocationPrice.TieredWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofTieredWithProration(tieredWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofUnitWithProration(unitWithProration)`. + */ + fun licenseAllocationPrice( + unitWithProration: LicenseAllocationPrice.UnitWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofUnitWithProration(unitWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation)`. + */ + fun licenseAllocationPrice( + groupedAllocation: LicenseAllocationPrice.GroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedAllocation(groupedAllocation) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofBulkWithProration(bulkWithProration)`. + */ + fun licenseAllocationPrice( + bulkWithProration: LicenseAllocationPrice.BulkWithProration + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofBulkWithProration(bulkWithProration) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithProratedMinimum: LicenseAllocationPrice.GroupedWithProratedMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun licenseAllocationPrice( + groupedWithMeteredMinimum: LicenseAllocationPrice.GroupedWithMeteredMinimum + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun licenseAllocationPrice( + groupedWithMinMaxThresholds: LicenseAllocationPrice.GroupedWithMinMaxThresholds + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun licenseAllocationPrice( + matrixWithDisplayName: LicenseAllocationPrice.MatrixWithDisplayName + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMatrixWithDisplayName(matrixWithDisplayName) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun licenseAllocationPrice( + groupedTieredPackage: LicenseAllocationPrice.GroupedTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofGroupedTieredPackage(groupedTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun licenseAllocationPrice( + maxGroupTieredPackage: LicenseAllocationPrice.MaxGroupTieredPackage + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofMaxGroupTieredPackage(maxGroupTieredPackage) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithUnitPricing: LicenseAllocationPrice.ScalableMatrixWithUnitPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun licenseAllocationPrice( + scalableMatrixWithTieredPricing: + LicenseAllocationPrice.ScalableMatrixWithTieredPricing + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedBulk: LicenseAllocationPrice.CumulativeGroupedBulk + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun licenseAllocationPrice( + cumulativeGroupedAllocation: LicenseAllocationPrice.CumulativeGroupedAllocation + ) = + licenseAllocationPrice( + LicenseAllocationPrice.ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation + ) + ) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofMinimumComposite(minimumComposite)`. + */ + fun licenseAllocationPrice(minimumComposite: LicenseAllocationPrice.MinimumComposite) = + licenseAllocationPrice(LicenseAllocationPrice.ofMinimumComposite(minimumComposite)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofPercent(percent)`. + */ + fun licenseAllocationPrice(percent: LicenseAllocationPrice.Percent) = + licenseAllocationPrice(LicenseAllocationPrice.ofPercent(percent)) + + /** + * Alias for calling [licenseAllocationPrice] with + * `LicenseAllocationPrice.ofEventOutput(eventOutput)`. + */ + fun licenseAllocationPrice(eventOutput: LicenseAllocationPrice.EventOutput) = + licenseAllocationPrice(LicenseAllocationPrice.ofEventOutput(eventOutput)) + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -1579,7 +1929,13 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Price = - Price(allocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap()) + Price( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1590,6 +1946,7 @@ private constructor( } allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } planPhaseOrder() price().ifPresent { it.validate() } validated = true @@ -1612,132 +1969,125 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = InnerPrice.Deserializer::class) - @JsonSerialize(using = InnerPrice.Serializer::class) - class InnerPrice + /** The license allocation price to add to the plan. */ + @JsonDeserialize(using = LicenseAllocationPrice.Deserializer::class) + @JsonSerialize(using = LicenseAllocationPrice.Serializer::class) + class LicenseAllocationPrice private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, + private val unit: Unit? = null, + private val tiered: Tiered? = null, + private val bulk: Bulk? = null, private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val minimumComposite: MinimumComposite? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, private val _json: JsonValue? = null, ) { - fun unit(): Optional = Optional.ofNullable(unit) + fun unit(): Optional = Optional.ofNullable(unit) - fun tiered(): Optional = Optional.ofNullable(tiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun bulk(): Optional = Optional.ofNullable(bulk) fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) - fun package_(): Optional = Optional.ofNullable(package_) + fun package_(): Optional = Optional.ofNullable(package_) - fun matrix(): Optional = Optional.ofNullable(matrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun thresholdTotalAmount(): Optional = + fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun tieredWithMinimum(): Optional = + fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) - fun tieredPackageWithMinimum(): Optional = + fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) - fun packageWithAllocation(): Optional = + fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun matrixWithAllocation(): Optional = + fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) - fun unitWithProration(): Optional = + fun unitWithProration(): Optional = Optional.ofNullable(unitWithProration) - fun groupedAllocation(): Optional = + fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) - fun bulkWithProration(): Optional = + fun bulkWithProration(): Optional = Optional.ofNullable(bulkWithProration) - fun groupedWithProratedMinimum(): Optional = + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) - fun groupedWithMeteredMinimum(): Optional = + fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) fun groupedWithMinMaxThresholds(): Optional = Optional.ofNullable(groupedWithMinMaxThresholds) - fun matrixWithDisplayName(): Optional = + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun groupedTieredPackage(): Optional = + fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) - fun maxGroupTieredPackage(): Optional = + fun maxGroupTieredPackage(): Optional = Optional.ofNullable(maxGroupTieredPackage) - fun scalableMatrixWithUnitPricing(): - Optional = + fun scalableMatrixWithUnitPricing(): Optional = Optional.ofNullable(scalableMatrixWithUnitPricing) - fun scalableMatrixWithTieredPricing(): - Optional = + fun scalableMatrixWithTieredPricing(): Optional = Optional.ofNullable(scalableMatrixWithTieredPricing) - fun cumulativeGroupedBulk(): Optional = + fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) - fun minimumComposite(): Optional = + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) fun percent(): Optional = Optional.ofNullable(percent) @@ -1807,85 +2157,82 @@ private constructor( fun isEventOutput(): Boolean = eventOutput != null - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + fun asThresholdTotalAmount(): ThresholdTotalAmount = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + fun asTieredWithMinimum(): TieredWithMinimum = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + fun asPackageWithAllocation(): PackageWithAllocation = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + fun asMatrixWithAllocation(): MatrixWithAllocation = matrixWithAllocation.getOrThrow("matrixWithAllocation") fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + fun asUnitWithProration(): UnitWithProration = unitWithProration.getOrThrow("unitWithProration") - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + fun asGroupedAllocation(): GroupedAllocation = groupedAllocation.getOrThrow("groupedAllocation") - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + fun asMatrixWithDisplayName(): MatrixWithDisplayName = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + fun asGroupedTieredPackage(): GroupedTieredPackage = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - fun asMinimumComposite(): NewPlanMinimumCompositePrice = + fun asMinimumComposite(): MinimumComposite = minimumComposite.getOrThrow("minimumComposite") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -1949,22 +2296,22 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerPrice = apply { + fun validate(): LicenseAllocationPrice = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { + override fun visitUnit(unit: Unit) { unit.validate() } - override fun visitTiered(tiered: NewPlanTieredPrice) { + override fun visitTiered(tiered: Tiered) { tiered.validate() } - override fun visitBulk(bulk: NewPlanBulkPrice) { + override fun visitBulk(bulk: Bulk) { bulk.validate() } @@ -1972,54 +2319,50 @@ private constructor( bulkWithFilters.validate() } - override fun visitPackage(package_: NewPlanPackagePrice) { + override fun visitPackage(package_: Package) { package_.validate() } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) { thresholdTotalAmount.validate() } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + override fun visitTieredPackage(tieredPackage: TieredPackage) { tieredPackage.validate() } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { tieredWithMinimum.validate() } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { groupedTiered.validate() } override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) { tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) { packageWithAllocation.validate() } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { unitWithPercent.validate() } override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) { matrixWithAllocation.validate() } @@ -2030,32 +2373,26 @@ private constructor( tieredWithProration.validate() } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { unitWithProration.validate() } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { groupedAllocation.validate() } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { bulkWithProration.validate() } override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { groupedWithMeteredMinimum.validate() } @@ -2067,38 +2404,37 @@ private constructor( } override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) { matrixWithDisplayName.validate() } override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) { groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) { maxGroupTieredPackage.validate() } override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { scalableMatrixWithUnitPricing.validate() } override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { scalableMatrixWithTieredPricing.validate() } override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) { cumulativeGroupedBulk.validate() } @@ -2109,9 +2445,7 @@ private constructor( cumulativeGroupedAllocation.validate() } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { minimumComposite.validate() } @@ -2145,72 +2479,66 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = bulkWithFilters.validity() - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + thresholdTotalAmount: ThresholdTotalAmount ) = thresholdTotalAmount.validity() - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + override fun visitTieredPackage(tieredPackage: TieredPackage) = tieredPackage.validity() - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = groupedTiered.validity() override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) = packageWithAllocation.validity() - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice + matrixWithAllocation: MatrixWithAllocation ) = matrixWithAllocation.validity() override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) = tieredWithProration.validity() - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) = groupedWithMeteredMinimum.validity() override fun visitGroupedWithMinMaxThresholds( @@ -2218,37 +2546,35 @@ private constructor( ) = groupedWithMinMaxThresholds.validity() override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) = matrixWithDisplayName.validity() override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice + groupedTieredPackage: GroupedTieredPackage ) = groupedTieredPackage.validity() override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = scalableMatrixWithUnitPricing.validity() override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = scalableMatrixWithTieredPricing.validity() override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() override fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = + minimumComposite.validity() override fun visitPercent(percent: Percent) = percent.validity() @@ -2264,7 +2590,7 @@ private constructor( return true } - return other is InnerPrice && + return other is LicenseAllocationPrice && unit == other.unit && tiered == other.tiered && bulk == other.bulk && @@ -2335,528 +2661,521 @@ private constructor( override fun toString(): String = when { - unit != null -> "InnerPrice{unit=$unit}" - tiered != null -> "InnerPrice{tiered=$tiered}" - bulk != null -> "InnerPrice{bulk=$bulk}" - bulkWithFilters != null -> "InnerPrice{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "InnerPrice{package_=$package_}" - matrix != null -> "InnerPrice{matrix=$matrix}" + unit != null -> "LicenseAllocationPrice{unit=$unit}" + tiered != null -> "LicenseAllocationPrice{tiered=$tiered}" + bulk != null -> "LicenseAllocationPrice{bulk=$bulk}" + bulkWithFilters != null -> + "LicenseAllocationPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "LicenseAllocationPrice{package_=$package_}" + matrix != null -> "LicenseAllocationPrice{matrix=$matrix}" thresholdTotalAmount != null -> - "InnerPrice{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "InnerPrice{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "InnerPrice{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" + "LicenseAllocationPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "LicenseAllocationPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> + "LicenseAllocationPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "LicenseAllocationPrice{groupedTiered=$groupedTiered}" tieredPackageWithMinimum != null -> - "InnerPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + "LicenseAllocationPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" packageWithAllocation != null -> - "InnerPrice{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "InnerPrice{unitWithPercent=$unitWithPercent}" + "LicenseAllocationPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> + "LicenseAllocationPrice{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> - "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" + "LicenseAllocationPrice{matrixWithAllocation=$matrixWithAllocation}" tieredWithProration != null -> - "InnerPrice{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "InnerPrice{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "InnerPrice{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" + "LicenseAllocationPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> + "LicenseAllocationPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> + "LicenseAllocationPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> + "LicenseAllocationPrice{bulkWithProration=$bulkWithProration}" groupedWithProratedMinimum != null -> - "InnerPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + "LicenseAllocationPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" groupedWithMeteredMinimum != null -> - "InnerPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + "LicenseAllocationPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" groupedWithMinMaxThresholds != null -> - "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + "LicenseAllocationPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" matrixWithDisplayName != null -> - "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" + "LicenseAllocationPrice{matrixWithDisplayName=$matrixWithDisplayName}" groupedTieredPackage != null -> - "InnerPrice{groupedTieredPackage=$groupedTieredPackage}" + "LicenseAllocationPrice{groupedTieredPackage=$groupedTieredPackage}" maxGroupTieredPackage != null -> - "InnerPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + "LicenseAllocationPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" scalableMatrixWithUnitPricing != null -> - "InnerPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + "LicenseAllocationPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" scalableMatrixWithTieredPricing != null -> - "InnerPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + "LicenseAllocationPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" cumulativeGroupedBulk != null -> - "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + "LicenseAllocationPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> - "InnerPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "InnerPrice{minimumComposite=$minimumComposite}" - percent != null -> "InnerPrice{percent=$percent}" - eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" - _json != null -> "InnerPrice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InnerPrice") + "LicenseAllocationPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> + "LicenseAllocationPrice{minimumComposite=$minimumComposite}" + percent != null -> "LicenseAllocationPrice{percent=$percent}" + eventOutput != null -> "LicenseAllocationPrice{eventOutput=$eventOutput}" + _json != null -> "LicenseAllocationPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } companion object { - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = InnerPrice(unit = unit) + @JvmStatic fun ofUnit(unit: Unit) = LicenseAllocationPrice(unit = unit) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) + @JvmStatic fun ofTiered(tiered: Tiered) = LicenseAllocationPrice(tiered = tiered) - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + @JvmStatic fun ofBulk(bulk: Bulk) = LicenseAllocationPrice(bulk = bulk) @JvmStatic fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - InnerPrice(bulkWithFilters = bulkWithFilters) + LicenseAllocationPrice(bulkWithFilters = bulkWithFilters) @JvmStatic - fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) + fun ofPackage(package_: Package) = LicenseAllocationPrice(package_ = package_) - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) + @JvmStatic fun ofMatrix(matrix: Matrix) = LicenseAllocationPrice(matrix = matrix) @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - InnerPrice(thresholdTotalAmount = thresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + LicenseAllocationPrice(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - InnerPrice(tieredPackage = tieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + LicenseAllocationPrice(tieredPackage = tieredPackage) @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - InnerPrice(tieredWithMinimum = tieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + LicenseAllocationPrice(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - InnerPrice(groupedTiered = groupedTiered) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + LicenseAllocationPrice(groupedTiered = groupedTiered) @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + LicenseAllocationPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = InnerPrice(packageWithAllocation = packageWithAllocation) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + LicenseAllocationPrice(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - InnerPrice(unitWithPercent = unitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + LicenseAllocationPrice(unitWithPercent = unitWithPercent) @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - InnerPrice(matrixWithAllocation = matrixWithAllocation) + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + LicenseAllocationPrice(matrixWithAllocation = matrixWithAllocation) @JvmStatic fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - InnerPrice(tieredWithProration = tieredWithProration) + LicenseAllocationPrice(tieredWithProration = tieredWithProration) @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - InnerPrice(unitWithProration = unitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + LicenseAllocationPrice(unitWithProration = unitWithProration) @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - InnerPrice(groupedAllocation = groupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + LicenseAllocationPrice(groupedAllocation = groupedAllocation) @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - InnerPrice(bulkWithProration = bulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + LicenseAllocationPrice(bulkWithProration = bulkWithProration) @JvmStatic fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = InnerPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = LicenseAllocationPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = InnerPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = LicenseAllocationPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic fun ofGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = InnerPrice(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + ) = + LicenseAllocationPrice( + groupedWithMinMaxThresholds = groupedWithMinMaxThresholds + ) @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + LicenseAllocationPrice(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - InnerPrice(groupedTieredPackage = groupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + LicenseAllocationPrice(groupedTieredPackage = groupedTieredPackage) @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = InnerPrice(maxGroupTieredPackage = maxGroupTieredPackage) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + LicenseAllocationPrice(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = InnerPrice(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing + ) @JvmStatic fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = InnerPrice(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing + ) @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + LicenseAllocationPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic fun ofCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = InnerPrice(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + ) = + LicenseAllocationPrice( + cumulativeGroupedAllocation = cumulativeGroupedAllocation + ) @JvmStatic - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - InnerPrice(minimumComposite = minimumComposite) + fun ofMinimumComposite(minimumComposite: MinimumComposite) = + LicenseAllocationPrice(minimumComposite = minimumComposite) - @JvmStatic fun ofPercent(percent: Percent) = InnerPrice(percent = percent) + @JvmStatic + fun ofPercent(percent: Percent) = LicenseAllocationPrice(percent = percent) @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) + fun ofEventOutput(eventOutput: EventOutput) = + LicenseAllocationPrice(eventOutput = eventOutput) } /** - * An interface that defines how to map each variant of [InnerPrice] to a value of type - * [T]. + * An interface that defines how to map each variant of [LicenseAllocationPrice] to a + * value of type [T]. */ interface Visitor { - fun visitUnit(unit: NewPlanUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitTiered(tiered: NewPlanTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitBulk(bulk: NewPlanBulkPrice): T + fun visitBulk(bulk: Bulk): T fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T - fun visitPackage(package_: NewPlanPackagePrice): T + fun visitPackage(package_: Package): T - fun visitMatrix(matrix: NewPlanMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ): T - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T fun visitGroupedWithMinMaxThresholds( groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds ): T - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T fun visitCumulativeGroupedAllocation( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun visitMinimumComposite(minimumComposite: MinimumComposite): T fun visitPercent(percent: Percent): T fun visitEventOutput(eventOutput: EventOutput): T /** - * Maps an unknown variant of [InnerPrice] to a value of type [T]. + * Maps an unknown variant of [LicenseAllocationPrice] to a value of type [T]. * - * An instance of [InnerPrice] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [LicenseAllocationPrice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws OrbInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown InnerPrice: $json") + throw OrbInvalidDataException("Unknown LicenseAllocationPrice: $json") } } - internal class Deserializer : BaseDeserializer(InnerPrice::class) { + internal class Deserializer : + BaseDeserializer(LicenseAllocationPrice::class) { - override fun ObjectCodec.deserialize(node: JsonNode): InnerPrice { + override fun ObjectCodec.deserialize(node: JsonNode): LicenseAllocationPrice { val json = JsonValue.fromJsonNode(node) val modelType = json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(unit = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unit = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(tiered = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(bulk = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_filters" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(bulkWithFilters = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice(bulkWithFilters = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(package_ = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(package_ = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(matrix = it, _json = json) - } ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(matrix = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(thresholdTotalAmount = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(thresholdTotalAmount = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(tieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(tieredWithMinimum = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(groupedTiered = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedTiered = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + tieredPackageWithMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(packageWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(packageWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(unitWithPercent = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithPercent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(tieredWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + ?.let { + LicenseAllocationPrice(tieredWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(unitWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(unitWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(groupedAllocation = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(bulkWithProration = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(bulkWithProration = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { InnerPrice(groupedWithProratedMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithProratedMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice( + groupedWithMeteredMinimum = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "grouped_with_min_max_thresholds" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { InnerPrice(groupedWithMinMaxThresholds = it, _json = json) } - ?: InnerPrice(_json = json) + ?.let { + LicenseAllocationPrice( + groupedWithMinMaxThresholds = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(matrixWithDisplayName = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedTieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(groupedTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(maxGroupTieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(maxGroupTieredPackage = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - InnerPrice(scalableMatrixWithUnitPricing = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice( + scalableMatrixWithUnitPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) ?.let { - InnerPrice(scalableMatrixWithTieredPricing = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice( + scalableMatrixWithTieredPricing = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + LicenseAllocationPrice(cumulativeGroupedBulk = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "cumulative_grouped_allocation" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { InnerPrice(cumulativeGroupedAllocation = it, _json = json) } - ?: InnerPrice(_json = json) + ?.let { + LicenseAllocationPrice( + cumulativeGroupedAllocation = it, + _json = json, + ) + } ?: LicenseAllocationPrice(_json = json) } "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(minimumComposite = it, _json = json) } - ?: InnerPrice(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + LicenseAllocationPrice(minimumComposite = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "percent" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(percent = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice(percent = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } "event_output" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(eventOutput = it, _json = json) - } ?: InnerPrice(_json = json) + LicenseAllocationPrice(eventOutput = it, _json = json) + } ?: LicenseAllocationPrice(_json = json) } } - return InnerPrice(_json = json) + return LicenseAllocationPrice(_json = json) } } - internal class Serializer : BaseSerializer(InnerPrice::class) { + internal class Serializer : + BaseSerializer(LicenseAllocationPrice::class) { override fun serialize( - value: InnerPrice, + value: LicenseAllocationPrice, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -2915,19 +3234,20 @@ private constructor( value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InnerPrice") + else -> throw IllegalStateException("Invalid LicenseAllocationPrice") } } } - class BulkWithFilters + class Unit @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val bulkWithFiltersConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, + private val licenseAllocations: JsonField>, private val modelType: JsonValue, private val name: JsonField, + private val unitConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -2940,6 +3260,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -2947,21 +3268,24 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -2998,6 +3322,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3005,11 +3332,12 @@ private constructor( @ExcludeMissing referenceId: JsonField = JsonMissing.of(), ) : this( - bulkWithFiltersConfig, cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3021,45 +3349,48 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), ) /** - * Configuration for bulk_with_filters pricing + * The cadence to bill for this price on. * * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + fun cadence(): Cadence = cadence.getRequired("cadence") /** - * The cadence to bill for this price on. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException 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") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. * * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3076,6 +3407,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException 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 unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3180,6 +3520,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -3199,17 +3547,6 @@ private constructor( */ fun referenceId(): Optional = referenceId.getOptional("reference_id") - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig - /** * Returns the raw JSON value of [cadence]. * @@ -3228,6 +3565,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + /** * Returns the raw JSON value of [name]. * @@ -3236,6 +3583,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -3349,6 +3706,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3384,27 +3751,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithFilters]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { - private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null + private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -3422,49 +3792,36 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + licenseAllocations = unit.licenseAllocations.map { it.toMutableList() } + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + conversionRateConfig = unit.conversionRateConfig + currency = unit.currency + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + licenseTypeId = unit.licenseTypeId + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) - - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } - /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -3489,13 +3846,45 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("bulk_with_filters") + * JsonValue.from("unit") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -3515,6 +3904,20 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -3863,6 +4266,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -3927,27 +4351,31 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithFilters]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .bulkWithFiltersConfig() * .cadence() * .itemId() + * .licenseAllocations() * .name() + * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, modelType, checkRequired("name", name), + checkRequired("unitConfig", unitConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3959,6 +4387,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -3967,20 +4396,21 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { + fun validate(): Unit = apply { if (validated) { return@apply } - bulkWithFiltersConfig().validate() cadence().validate() itemId() + licenseAllocations().forEach { it.validate() } _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { + if (it != JsonValue.from("unit")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + unitConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -3992,6 +4422,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -4013,11 +4444,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -4029,65 +4462,247 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) /** - * Property filters to apply (all must match) + * The amount of credits granted per active license per cadence. * * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + fun amount(): String = amount.getRequired("amount") /** - * Bulk tiers for rating based on total usage volume + * The currency of the license allocation. * * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + fun currency(): String = currency.getRequired("currency") /** - * Returns the raw JSON value of [filters]. + * When True, overage beyond the allocation is written off. * - * Unlike [filters], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("filters") + @JsonProperty("amount") @ExcludeMissing - fun _filters(): JsonField> = filters + fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [tiers]. + * Returns the raw JSON value of [currency]. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiers") + @JsonProperty("currency") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4105,85 +4720,69677 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. + * [LicenseAllocation]. * * The following fields are required: * ```java - * .filters() - * .tiers() + * .amount() + * .currency() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithFiltersConfig]. */ + /** A builder for [LicenseAllocation]. */ class Builder internal constructor() { - private var filters: JsonField>? = null - private var tiers: JsonField>? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() + licenseAllocation.additionalProperties.toMutableMap() } - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) /** - * Sets [Builder.filters] to an arbitrary JSON value. + * Sets [Builder.amount] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Adds a single [Filter] to [filters]. + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } + fun currency(currency: JsonField) = apply { + this.currency = currency } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Alias for [Builder.writeOffOverage]. * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) /** - * Adds a single [Tier] to [tiers]. + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Unit && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Unit{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Tiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered pricing + * + * @throws OrbInvalidDataException 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 tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredConfig]. + * + * Unlike [tieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Tiered]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered") + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + licenseAllocations = tiered.licenseAllocations.map { it.toMutableList() } + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + conversionRateConfig = tiered.conversionRateConfig + currency = tiered.currency + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + licenseTypeId = tiered.licenseTypeId + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered pricing */ + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) + + /** + * Sets [Builder.tieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredConfig] with a well-typed + * [TieredConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Tiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tiered = + Tiered( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tiered && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredConfig == other.tieredConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tiered{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Bulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk pricing + * + * @throws OrbInvalidDataException 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 bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkConfig]. + * + * Unlike [bulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Bulk]. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Bulk]. */ + class Builder internal constructor() { + + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + licenseAllocations = bulk.licenseAllocations.map { it.toMutableList() } + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + conversionRateConfig = bulk.conversionRateConfig + currency = bulk.currency + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + licenseTypeId = bulk.licenseTypeId + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() + } + + /** Configuration for bulk pricing */ + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + /** + * Sets [Builder.bulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkConfig] with a well-typed [BulkConfig] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Bulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Bulk = + Bulk( + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Bulk = apply { + if (validated) { + return@apply + } + + bulkConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Bulk && + bulkConfig == other.bulkConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + licenseAllocations = + bulkWithFilters.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException 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 propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException 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 propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @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 [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + 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 [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Package + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package pricing + * + * @throws OrbInvalidDataException 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 packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageConfig]. + * + * Unlike [packageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Package]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Package]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package") + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + licenseAllocations = package_.licenseAllocations.map { it.toMutableList() } + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + conversionRateConfig = package_.conversionRateConfig + currency = package_.currency + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + licenseTypeId = package_.licenseTypeId + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package pricing */ + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + /** + * Sets [Builder.packageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageConfig] with a well-typed + * [PackageConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Package]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Package = + Package( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Package = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Package && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageConfig == other.packageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Package{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Matrix + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix pricing + * + * @throws OrbInvalidDataException 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 matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixConfig]. + * + * Unlike [matrixConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Matrix]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Matrix]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + licenseAllocations = matrix.licenseAllocations.map { it.toMutableList() } + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + conversionRateConfig = matrix.conversionRateConfig + currency = matrix.currency + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + licenseTypeId = matrix.licenseTypeId + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix pricing */ + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + /** + * Sets [Builder.matrixConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixConfig] with a well-typed + * [MatrixConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Matrix]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Matrix = + Matrix( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixConfig", matrixConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Matrix = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Matrix && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixConfig == other.matrixConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Matrix{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ThresholdTotalAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val thresholdTotalAmountConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for threshold_total_amount pricing + * + * @throws OrbInvalidDataException 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 thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [thresholdTotalAmountConfig]. + * + * Unlike [thresholdTotalAmountConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ThresholdTotalAmount]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmount]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + licenseAllocations = + thresholdTotalAmount.licenseAllocations.map { it.toMutableList() } + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + conversionRateConfig = thresholdTotalAmount.conversionRateConfig + currency = thresholdTotalAmount.currency + dimensionalPriceConfiguration = + thresholdTotalAmount.dimensionalPriceConfiguration + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = + thresholdTotalAmount.invoicingCycleConfiguration + licenseTypeId = thresholdTotalAmount.licenseTypeId + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId + additionalProperties = + thresholdTotalAmount.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for threshold_total_amount pricing */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + /** + * Sets [Builder.thresholdTotalAmountConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdTotalAmountConfig] with a + * well-typed [ThresholdTotalAmountConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ThresholdTotalAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .thresholdTotalAmountConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmount = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for threshold_total_amount pricing */ + class ThresholdTotalAmountConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val consumptionTable: JsonField>, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("consumption_table") + @ExcludeMissing + consumptionTable: JsonField> = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(consumptionTable, prorate, mutableMapOf()) + + /** + * When the quantity consumed passes a provided threshold, the configured total + * will be charged + * + * @throws OrbInvalidDataException 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 consumptionTable(): List = + consumptionTable.getRequired("consumption_table") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [consumptionTable]. + * + * Unlike [consumptionTable], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_table") + @ExcludeMissing + fun _consumptionTable(): JsonField> = consumptionTable + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [ThresholdTotalAmountConfig]. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountConfig]. */ + class Builder internal constructor() { + + private var consumptionTable: JsonField>? = + null + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + apply { + consumptionTable = + thresholdTotalAmountConfig.consumptionTable.map { + it.toMutableList() + } + prorate = thresholdTotalAmountConfig.prorate + additionalProperties = + thresholdTotalAmountConfig.additionalProperties.toMutableMap() + } + + /** + * When the quantity consumed passes a provided threshold, the configured + * total will be charged + */ + fun consumptionTable(consumptionTable: List) = + consumptionTable(JsonField.of(consumptionTable)) + + /** + * Sets [Builder.consumptionTable] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionTable] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumptionTable(consumptionTable: JsonField>) = + apply { + this.consumptionTable = consumptionTable.map { it.toMutableList() } + } + + /** + * Adds a single [ConsumptionTable] to [Builder.consumptionTable]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addConsumptionTable(consumptionTable: ConsumptionTable) = apply { + this.consumptionTable = + (this.consumptionTable ?: JsonField.of(mutableListOf())).also { + checkKnown("consumptionTable", it).add(consumptionTable) + } + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [ThresholdTotalAmountConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .consumptionTable() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig( + checkRequired("consumptionTable", consumptionTable).map { + it.toImmutable() + }, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (validated) { + return@apply + } + + consumptionTable().forEach { it.validate() } + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (consumptionTable.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single threshold */ + class ConsumptionTable + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val threshold: JsonField, + private val totalAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + @JsonProperty("total_amount") + @ExcludeMissing + totalAmount: JsonField = JsonMissing.of(), + ) : this(threshold, totalAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 threshold(): String = threshold.getRequired("threshold") + + /** + * Total amount for this threshold + * + * @throws OrbInvalidDataException 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 totalAmount(): String = totalAmount.getRequired("total_amount") + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + /** + * Returns the raw JSON value of [totalAmount]. + * + * Unlike [totalAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("total_amount") + @ExcludeMissing + fun _totalAmount(): JsonField = totalAmount + + @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 + * [ConsumptionTable]. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumptionTable]. */ + class Builder internal constructor() { + + private var threshold: JsonField? = null + private var totalAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumptionTable: ConsumptionTable) = apply { + threshold = consumptionTable.threshold + totalAmount = consumptionTable.totalAmount + additionalProperties = + consumptionTable.additionalProperties.toMutableMap() + } + + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + /** Total amount for this threshold */ + fun totalAmount(totalAmount: String) = + totalAmount(JsonField.of(totalAmount)) + + /** + * Sets [Builder.totalAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun totalAmount(totalAmount: JsonField) = apply { + this.totalAmount = totalAmount + } + + 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 [ConsumptionTable]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .threshold() + * .totalAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumptionTable = + ConsumptionTable( + checkRequired("threshold", threshold), + checkRequired("totalAmount", totalAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumptionTable = apply { + if (validated) { + return@apply + } + + threshold() + totalAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (threshold.asKnown().isPresent) 1 else 0) + + (if (totalAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumptionTable && + threshold == other.threshold && + totalAmount == other.totalAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(threshold, totalAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumptionTable{threshold=$threshold, totalAmount=$totalAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmountConfig && + consumptionTable == other.consumptionTable && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(consumptionTable, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdTotalAmount && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + thresholdTotalAmountConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package pricing + * + * @throws OrbInvalidDataException 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 tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageConfig]. + * + * Unlike [tieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [TieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package") + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + licenseAllocations = + tieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + conversionRateConfig = tieredPackage.conversionRateConfig + currency = tieredPackage.currency + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + licenseTypeId = tieredPackage.licenseTypeId + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package pricing */ + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + /** + * Sets [Builder.tieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageConfig] with a well-typed + * [TieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackage = + TieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package pricing */ + class TieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are defined + * based on the total quantity rather than the number of packages, so they must + * be multiples of the package size. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + packageSize = tieredPackageConfig.packageSize + tiers = tieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. The tier bounds are + * defined based on the total quantity rather than the number of packages, + * so they must be multiples of the package size. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Price per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Price per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageConfig == other.tieredPackageConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithMinimumConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithMinimumConfig]. + * + * Unlike [tieredWithMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + licenseAllocations = + tieredWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + conversionRateConfig = tieredWithMinimum.conversionRateConfig + currency = tieredWithMinimum.currency + dimensionalPriceConfiguration = + tieredWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredWithMinimum.licenseTypeId + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_minimum pricing */ + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + /** + * Sets [Builder.tieredWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithMinimumConfig] with a well-typed + * [TieredWithMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimum = + TieredWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_minimum pricing */ + class TieredWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val hideZeroAmountTiers: JsonField, + private val prorate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + hideZeroAmountTiers: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + ) : this(tiers, hideZeroAmountTiers, prorate, mutableMapOf()) + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers are + * defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun hideZeroAmountTiers(): Optional = + hideZeroAmountTiers.getOptional("hide_zero_amount_tiers") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [hideZeroAmountTiers]. + * + * Unlike [hideZeroAmountTiers], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("hide_zero_amount_tiers") + @ExcludeMissing + fun _hideZeroAmountTiers(): JsonField = hideZeroAmountTiers + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + @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 + * [TieredWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var hideZeroAmountTiers: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = + apply { + tiers = tieredWithMinimumConfig.tiers.map { it.toMutableList() } + hideZeroAmountTiers = tieredWithMinimumConfig.hideZeroAmountTiers + prorate = tieredWithMinimumConfig.prorate + additionalProperties = + tieredWithMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Tiered pricing with a minimum amount dependent on the volume tier. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** + * If true, tiers with an accrued amount of 0 will not be included in the + * rating. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: Boolean) = + hideZeroAmountTiers(JsonField.of(hideZeroAmountTiers)) + + /** + * Sets [Builder.hideZeroAmountTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.hideZeroAmountTiers] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun hideZeroAmountTiers(hideZeroAmountTiers: JsonField) = apply { + this.hideZeroAmountTiers = hideZeroAmountTiers + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean) = prorate(JsonField.of(prorate)) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + 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 [TieredWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + hideZeroAmountTiers, + prorate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + hideZeroAmountTiers() + prorate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hideZeroAmountTiers.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(minimumAmount, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimumConfig && + tiers == other.tiers && + hideZeroAmountTiers == other.hideZeroAmountTiers && + prorate == other.prorate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tiers, hideZeroAmountTiers, prorate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithMinimumConfig == other.tieredWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTiered + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered pricing + * + * @throws OrbInvalidDataException 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 groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredConfig]. + * + * Unlike [groupedTieredConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [GroupedTiered]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTiered]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + licenseAllocations = + groupedTiered.licenseAllocations.map { it.toMutableList() } + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + conversionRateConfig = groupedTiered.conversionRateConfig + currency = groupedTiered.currency + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + licenseTypeId = groupedTiered.licenseTypeId + metadata = groupedTiered.metadata + referenceId = groupedTiered.referenceId + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered pricing */ + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + /** + * Sets [Builder.groupedTieredConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredConfig] with a well-typed + * [GroupedTieredConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTiered]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTiered = + GroupedTiered( + checkRequired("cadence", cadence), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTiered = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered pricing */ + class GroupedTieredConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, tiers, mutableMapOf()) + + /** + * The billable metric property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + groupingKey = groupedTieredConfig.groupingKey + tiers = groupedTieredConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredConfig.additionalProperties.toMutableMap() + } + + /** The billable metric property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Apply tiered pricing to each segment generated after grouping with the + * provided key + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredConfig = + GroupedTieredConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredConfig && + groupingKey == other.groupingKey && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredConfig{groupingKey=$groupingKey, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTiered && + cadence == other.cadence && + groupedTieredConfig == other.groupedTieredConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTiered{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredPackageWithMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredPackageWithMinimumConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_package_with_minimum pricing + * + * @throws OrbInvalidDataException 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 tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredPackageWithMinimumConfig]. + * + * Unlike [tieredPackageWithMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredPackageWithMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") + private var name: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + itemId = tieredPackageWithMinimum.itemId + licenseAllocations = + tieredPackageWithMinimum.licenseAllocations.map { it.toMutableList() } + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + conversionRateConfig = tieredPackageWithMinimum.conversionRateConfig + currency = tieredPackageWithMinimum.currency + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + tieredPackageWithMinimum.invoicingCycleConfiguration + licenseTypeId = tieredPackageWithMinimum.licenseTypeId + metadata = tieredPackageWithMinimum.metadata + referenceId = tieredPackageWithMinimum.referenceId + additionalProperties = + tieredPackageWithMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_package_with_minimum pricing */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + /** + * Sets [Builder.tieredPackageWithMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredPackageWithMinimumConfig] with a + * well-typed [TieredPackageWithMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { + this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredPackageWithMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "tieredPackageWithMinimumConfig", + tieredPackageWithMinimumConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_package_with_minimum pricing */ + class TieredPackageWithMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(packageSize, tiers, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 packageSize(): Double = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredPackageWithMinimumConfig]. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumConfig]. */ + class Builder internal constructor() { + + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = apply { + packageSize = tieredPackageWithMinimumConfig.packageSize + tiers = tieredPackageWithMinimumConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() + } + + fun packageSize(packageSize: Double) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredPackageWithMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig( + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (validated) { + return@apply + } + + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(minimumAmount, perUnit, tierLowerBound, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + minimumAmount = tier.minimumAmount + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("minimumAmount", minimumAmount), + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + minimumAmount() + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + minimumAmount == other.minimumAmount && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + minimumAmount, + perUnit, + tierLowerBound, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{minimumAmount=$minimumAmount, perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimumConfig && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredPackageWithMinimum && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredPackageWithMinimumConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimum{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class PackageWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val packageWithAllocationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for package_with_allocation pricing + * + * @throws OrbInvalidDataException 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 packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [packageWithAllocationConfig]. + * + * Unlike [packageWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [PackageWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + licenseAllocations = + packageWithAllocation.licenseAllocations.map { it.toMutableList() } + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + conversionRateConfig = packageWithAllocation.conversionRateConfig + currency = packageWithAllocation.currency + dimensionalPriceConfiguration = + packageWithAllocation.dimensionalPriceConfiguration + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + packageWithAllocation.invoicingCycleConfiguration + licenseTypeId = packageWithAllocation.licenseTypeId + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId + additionalProperties = + packageWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for package_with_allocation pricing */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + /** + * Sets [Builder.packageWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.packageWithAllocationConfig] with a + * well-typed [PackageWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [PackageWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .packageWithAllocationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocation = + PackageWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "packageWithAllocationConfig", + packageWithAllocationConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("package_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (packageWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for package_with_allocation pricing */ + class PackageWithAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("package_amount") + @ExcludeMissing + packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + ) : this(allocation, packageAmount, packageSize, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * @throws OrbInvalidDataException 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 packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [packageAmount]. + * + * Unlike [packageAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + @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 + * [PackageWithAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = apply { + allocation = packageWithAllocationConfig.allocation + packageAmount = packageWithAllocationConfig.packageAmount + packageSize = packageWithAllocationConfig.packageSize + additionalProperties = + packageWithAllocationConfig.additionalProperties.toMutableMap() + } + + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** + * Sets [Builder.packageAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.packageAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + 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 [PackageWithAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .packageAmount() + * .packageSize() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + packageAmount() + packageSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (packageAmount.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocationConfig && + allocation == other.allocation && + packageAmount == other.packageAmount && + packageSize == other.packageSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, packageAmount, packageSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationConfig{allocation=$allocation, packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PackageWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + packageWithAllocationConfig == other.packageWithAllocationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + packageWithAllocationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithPercent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithPercentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_percent pricing + * + * @throws OrbInvalidDataException 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 unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithPercentConfig]. + * + * Unlike [unitWithPercentConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [UnitWithPercent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + licenseAllocations = + unitWithPercent.licenseAllocations.map { it.toMutableList() } + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + conversionRateConfig = unitWithPercent.conversionRateConfig + currency = unitWithPercent.currency + dimensionalPriceConfiguration = + unitWithPercent.dimensionalPriceConfiguration + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + licenseTypeId = unitWithPercent.licenseTypeId + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_percent pricing */ + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + /** + * Sets [Builder.unitWithPercentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithPercentConfig] with a well-typed + * [UnitWithPercentConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithPercent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithPercentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercent = + UnitWithPercent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_percent pricing */ + class UnitWithPercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(percent, unitAmount, mutableMapOf()) + + /** + * What percent, out of 100, of the calculated total to charge + * + * @throws OrbInvalidDataException 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 percent(): String = percent.getRequired("percent") + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithPercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + percent = unitWithPercentConfig.percent + unitAmount = unitWithPercentConfig.unitAmount + additionalProperties = + unitWithPercentConfig.additionalProperties.toMutableMap() + } + + /** What percent, out of 100, of the calculated total to charge */ + fun percent(percent: String) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithPercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig( + checkRequired("percent", percent), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (validated) { + return@apply + } + + percent() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercentConfig && + percent == other.percent && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithPercent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithPercentConfig == other.unitWithPercentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithPercentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithAllocationConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_allocation pricing + * + * @throws OrbInvalidDataException 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 matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithAllocationConfig]. + * + * Unlike [matrixWithAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + itemId = matrixWithAllocation.itemId + licenseAllocations = + matrixWithAllocation.licenseAllocations.map { it.toMutableList() } + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + conversionRateConfig = matrixWithAllocation.conversionRateConfig + currency = matrixWithAllocation.currency + dimensionalPriceConfiguration = + matrixWithAllocation.dimensionalPriceConfiguration + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithAllocation.invoicingCycleConfiguration + licenseTypeId = matrixWithAllocation.licenseTypeId + metadata = matrixWithAllocation.metadata + referenceId = matrixWithAllocation.referenceId + additionalProperties = + matrixWithAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_allocation pricing */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + /** + * Sets [Builder.matrixWithAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithAllocationConfig] with a + * well-typed [MatrixWithAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithAllocationConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithAllocation = + MatrixWithAllocation( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithAllocationConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithAllocation && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithAllocationConfig == other.matrixWithAllocationConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithAllocationConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocation{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException 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 tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + licenseAllocations = + tieredWithProration.licenseAllocations.map { it.toMutableList() } + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val unitWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException 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 unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [UnitWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + licenseAllocations = + unitWithProration.licenseAllocations.map { it.toMutableList() } + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + currency = unitWithProration.currency + dimensionalPriceConfiguration = + unitWithProration.dimensionalPriceConfiguration + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + licenseTypeId = unitWithProration.licenseTypeId + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = + apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitWithProrationConfig == other.unitWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedAllocationConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + licenseAllocations = + groupedAllocation.licenseAllocations.map { it.toMutableList() } + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + currency = groupedAllocation.currency + dimensionalPriceConfiguration = + groupedAllocation.dimensionalPriceConfiguration + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + licenseTypeId = groupedAllocation.licenseTypeId + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException 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 allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException 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 overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @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 + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = + apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * How to determine the groups that should each be allocated some quantity + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + 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 [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + cadence == other.cadence && + groupedAllocationConfig == other.groupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException 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 bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [BulkWithProration]. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + licenseAllocations = + bulkWithProration.licenseAllocations.map { it.toMutableList() } + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + currency = bulkWithProration.currency + dimensionalPriceConfiguration = + bulkWithProration.dimensionalPriceConfiguration + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + licenseTypeId = bulkWithProration.licenseTypeId + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = + apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithProrationConfig, + cadence, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithProratedMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + licenseAllocations = + groupedWithProratedMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + currency = groupedWithProratedMinimum.currency + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithProratedMinimum.licenseTypeId + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a + * well-typed [GroupedWithProratedMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithProratedMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException 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 minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException 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 unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rate") + @ExcludeMissing + fun _unitRate(): JsonField = unitRate + + @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 + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { + this.unitRate = unitRate + } + + 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 [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimum && + cadence == other.cadence && + groupedWithProratedMinimumConfig == + other.groupedWithProratedMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithProratedMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMeteredMinimumConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException 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 groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + licenseAllocations = + groupedWithMeteredMinimum.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + currency = groupedWithMeteredMinimum.currency + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + licenseTypeId = groupedWithMeteredMinimum.licenseTypeId + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a + * well-typed [GroupedWithMeteredMinimumConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { + this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMeteredMinimumConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException 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 minimumUnitAmount(): String = + minimumUnitAmount.getRequired("minimum_unit_amount") + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 pricingKey(): String = pricingKey.getRequired("pricing_key") + + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException 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 scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") + + /** + * Used to determine the unit rate scaling factor + * + * @throws OrbInvalidDataException 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 scalingKey(): String = scalingKey.getRequired("scaling_key") + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied + * any unmatched usage. + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimumUnitAmount]. + * + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount + + /** + * Returns the raw JSON value of [pricingKey]. + * + * Unlike [pricingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. + * + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors + + /** + * Returns the raw JSON value of [scalingKey]. + * + * Unlike [scalingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { + it.toMutableList() + } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { + it.toMutableList() + } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to + * each group. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is + * applied any unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { + it.toImmutable() + }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException 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 scalingValue(): String = scalingValue.getRequired("scaling_value") + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") + @ExcludeMissing + fun _scalingValue(): JsonField = scalingValue + + @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 + * [ScalingFactor]. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = + scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) + + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } + + 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 [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply + } + + scalingFactor() + scalingValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pricingValue: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(pricingValue, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 pricingValue(): String = pricingValue.getRequired("pricing_value") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [pricingValue]. + * + * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pricing_value") + @ExcludeMissing + fun _pricingValue(): JsonField = pricingValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var pricingValue: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .pricingValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + pricingValue() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + pricingValue == other.pricingValue && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pricingValue, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMeteredMinimum && + cadence == other.cadence && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMeteredMinimumConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException 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 groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + licenseAllocations = + groupedWithMinMaxThresholds.licenseAllocations.map { + it.toMutableList() + } + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException 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 maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException 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 minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException 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 perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @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 + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + 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 [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithDisplayName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val matrixWithDisplayNameConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException 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 matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MatrixWithDisplayName]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayName]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + licenseAllocations = + matrixWithDisplayName.licenseAllocations.map { it.toMutableList() } + matrixWithDisplayNameConfig = + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + currency = matrixWithDisplayName.currency + dimensionalPriceConfiguration = + matrixWithDisplayName.dimensionalPriceConfiguration + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithDisplayName.invoicingCycleConfiguration + licenseTypeId = matrixWithDisplayName.licenseTypeId + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId + additionalProperties = + matrixWithDisplayName.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a + * well-typed [MatrixWithDisplayNameConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MatrixWithDisplayName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .matrixWithDisplayNameConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "matrixWithDisplayNameConfig", + matrixWithDisplayNameConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayName = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + matrixWithDisplayNameConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimension: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension") + @ExcludeMissing + dimension: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this(dimension, unitAmounts, mutableMapOf()) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 dimension(): String = dimension.getRequired("dimension") + + /** + * Apply per unit pricing to each dimension value + * + * @throws OrbInvalidDataException 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 unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + + /** + * Returns the raw JSON value of [dimension]. + * + * Unlike [dimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension") + @ExcludeMissing + fun _dimension(): JsonField = dimension + + /** + * Returns the raw JSON value of [unitAmounts]. + * + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @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 + * [MatrixWithDisplayNameConfig]. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNameConfig]. */ + class Builder internal constructor() { + + private var dimension: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } + + /** Used to determine the unit rate */ + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + + /** + * Sets [Builder.dimension] to an arbitrary JSON value. + * + * You should usually call [Builder.dimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dimension(dimension: JsonField) = apply { + this.dimension = dimension + } + + /** Apply per unit pricing to each dimension value */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + 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 [MatrixWithDisplayNameConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimension() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply + } + + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Configuration for a unit amount item */ + class UnitAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValue: JsonField, + private val displayName: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_value") + @ExcludeMissing + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) + + /** + * The dimension value + * + * @throws OrbInvalidDataException 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 dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException 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 displayName(): String = displayName.getRequired("display_name") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValue]. + * + * Unlike [dimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_value") + @ExcludeMissing + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [UnitAmount]. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitAmount]. */ + class Builder internal constructor() { + + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unitAmount: UnitAmount) = apply { + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName + this.unitAmount = unitAmount.unitAmount + additionalProperties = + unitAmount.additionalProperties.toMutableMap() + } + + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) + + /** + * Sets [Builder.dimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = + displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [UnitAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValue() + * .displayName() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitAmount = + UnitAmount( + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnitAmount = apply { + if (validated) { + return@apply + } + + dimensionValue() + displayName() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitAmount && + dimensionValue == other.dimensionValue && + displayName == other.displayName && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dimensionValue, + displayName, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && + unitAmounts == other.unitAmounts && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimension, unitAmounts, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithDisplayName && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + matrixWithDisplayNameConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for grouped_tiered_package pricing + * + * @throws OrbInvalidDataException 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 groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [groupedTieredPackageConfig]. + * + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [GroupedTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + licenseAllocations = + groupedTieredPackage.licenseAllocations.map { it.toMutableList() } + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + currency = groupedTieredPackage.currency + dimensionalPriceConfiguration = + groupedTieredPackage.dimensionalPriceConfiguration + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + groupedTieredPackage.invoicingCycleConfiguration + licenseTypeId = groupedTieredPackage.licenseTypeId + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId + additionalProperties = + groupedTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + /** + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedTieredPackageConfig] with a + * well-typed [GroupedTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [GroupedTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackage = + GroupedTieredPackage( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + groupedTieredPackageConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [GroupedTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + groupedTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before tiering */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing after rounding up the quantity to the package size. + * Tiers are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [GroupedTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException 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 perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { + this.perUnit = perUnit + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedTieredPackage && + cadence == other.cadence && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + groupedTieredPackageConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MaxGroupTieredPackage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val maxGroupTieredPackageConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for max_group_tiered_package pricing + * + * @throws OrbInvalidDataException 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 maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. + * + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [MaxGroupTieredPackage]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackage]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var maxGroupTieredPackageConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + licenseAllocations = + maxGroupTieredPackage.licenseAllocations.map { it.toMutableList() } + maxGroupTieredPackageConfig = + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + currency = maxGroupTieredPackage.currency + dimensionalPriceConfiguration = + maxGroupTieredPackage.dimensionalPriceConfiguration + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = + maxGroupTieredPackage.invoicingCycleConfiguration + licenseTypeId = maxGroupTieredPackage.licenseTypeId + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId + additionalProperties = + maxGroupTieredPackage.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + /** + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.maxGroupTieredPackageConfig] with a + * well-typed [MaxGroupTieredPackageConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MaxGroupTieredPackage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .maxGroupTieredPackageConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired( + "maxGroupTieredPackageConfig", + maxGroupTieredPackageConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackage = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + maxGroupTieredPackageConfig().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + + /** + * The event property used to group before tiering the group with the highest + * value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * @throws OrbInvalidDataException 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 packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided + * key. + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [packageSize]. + * + * Unlike [packageSize], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [MaxGroupTieredPackageConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackageConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = apply { + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } + additionalProperties = + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + } + + /** + * The event property used to group before tiering the group with the + * highest value + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun packageSize(packageSize: String) = + packageSize(JsonField.of(packageSize)) + + /** + * Sets [Builder.packageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.packageSize] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } + + /** + * Apply tiered pricing to the largest group after grouping with the + * provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + 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 [MaxGroupTieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .packageSize() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackageConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + packageSize() + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Per unit amount + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Per unit amount */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxGroupTieredPackage && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + maxGroupTieredPackageConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithUnitPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): + JsonField = + scalableMatrixWithUnitPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithUnitPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + licenseAllocations = + scalableMatrixWithUnitPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + currency = scalableMatrixWithUnitPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithUnitPricing.licenseTypeId + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithUnitPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, + private val groupingKey: JsonField, + private val prorate: JsonField, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("prorate") + @ExcludeMissing + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) + + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * The final unit price to rate against the output of the matrix + * + * @throws OrbInvalidDataException 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 unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [prorate]. + * + * Unlike [prorate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorate") + @ExcludeMissing + fun _prorate(): JsonField = prorate + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithUnitPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithUnitPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { + this.unitPrice = unitPrice + } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + + /** + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + + /** + * Sets [Builder.prorate] to an arbitrary JSON value. + * + * You should usually call [Builder.prorate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithUnitPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() + groupingKey() + prorate() + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && + groupingKey == other.groupingKey && + prorate == other.prorate && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithUnitPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithUnitPricingConfig == + other.scalableMatrixWithUnitPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithUnitPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class ScalableMatrixWithTieredPricing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException 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 scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = + scalableMatrixWithTieredPricingConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [ScalableMatrixWithTieredPricing]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricing]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = apply { + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + licenseAllocations = + scalableMatrixWithTieredPricing.licenseAllocations.map { + it.toMutableList() + } + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + currency = scalableMatrixWithTieredPricing.currency + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + licenseTypeId = scalableMatrixWithTieredPricing.licenseTypeId + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON + * value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with + * a well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [ScalableMatrixWithTieredPricing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricing = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() + ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val tiers: JsonField>, + private val secondDimension: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = + JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + mutableMapOf(), + ) + + /** + * Used for the scalable matrix first dimension + * + * @throws OrbInvalidDataException 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 firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Apply a scaling factor to each dimension + * + * @throws OrbInvalidDataException 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 matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") + + /** + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Used for the scalable matrix second dimension (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = + matrixScalingFactors + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + @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 + * [ScalableMatrixWithTieredPricingConfig]. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: + JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricingConfig: + ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = + scalableMatrixWithTieredPricingConfig.tiers.map { + it.toMutableList() + } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties + .toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = + matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = + apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it) + .add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + 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 [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException 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 scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @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 + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + 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 [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + tiers == other.tiers && + secondDimension == other.secondDimension && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ScalableMatrixWithTieredPricing && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + scalableMatrixWithTieredPricingConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedBulk + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedBulk]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulk]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + licenseAllocations = + cumulativeGroupedBulk.licenseAllocations.map { it.toMutableList() } + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + currency = cumulativeGroupedBulk.currency + dimensionalPriceConfiguration = + cumulativeGroupedBulk.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedBulk.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedBulk.licenseTypeId + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId + additionalProperties = + cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a + * well-typed [CumulativeGroupedBulkConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedBulkConfig", + cumulativeGroupedBulkConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedBulkConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val group: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") + @ExcludeMissing + group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) + + /** + * Each tier lower bound must have the same group of values. + * + * @throws OrbInvalidDataException 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 dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * @throws OrbInvalidDataException 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 group(): String = group.getRequired("group") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [group]. + * + * Unlike [group], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + + @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 + * [CumulativeGroupedBulkConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkConfig]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { + it.toMutableList() + } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } + + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = + apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [DimensionValue] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + + 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 [CumulativeGroupedBulkConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .group() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("group", group), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkConfig = apply { + if (validated) { + return@apply + } + + dimensionValues().forEach { it.validate() } + group() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + (if (group.asKnown().isPresent) 1 else 0) + + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Grouping key value + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Tier lower bound + * + * @throws OrbInvalidDataException 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 tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Unit amount for this combination + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [DimensionValue]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = + dimensionValue.additionalProperties.toMutableMap() + } + + /** Grouping key value */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DimensionValue = apply { + if (validated) { + return@apply + } + + groupingKey() + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + tierLowerBound, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, group, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedBulk && + cadence == other.cadence && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedBulkConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException 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 cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + licenseAllocations = + cumulativeGroupedAllocation.licenseAllocations.map { + it.toMutableList() + } + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException 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 cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException 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 groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException 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 unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @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 + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + 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 [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MinimumComposite + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val minimumCompositeConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_composite_config") + @ExcludeMissing + minimumCompositeConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * Configuration for minimum_composite pricing + * + * @throws OrbInvalidDataException 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 minimumCompositeConfig(): MinimumCompositeConfig = + minimumCompositeConfig.getRequired("minimum_composite_config") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("minimum_composite") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [minimumCompositeConfig]. + * + * Unlike [minimumCompositeConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("minimum_composite_config") + @ExcludeMissing + fun _minimumCompositeConfig(): JsonField = + minimumCompositeConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [MinimumComposite]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumComposite]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var minimumCompositeConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("minimum_composite") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumComposite: MinimumComposite) = apply { + cadence = minimumComposite.cadence + itemId = minimumComposite.itemId + licenseAllocations = + minimumComposite.licenseAllocations.map { it.toMutableList() } + minimumCompositeConfig = minimumComposite.minimumCompositeConfig + modelType = minimumComposite.modelType + name = minimumComposite.name + billableMetricId = minimumComposite.billableMetricId + billedInAdvance = minimumComposite.billedInAdvance + billingCycleConfiguration = minimumComposite.billingCycleConfiguration + conversionRate = minimumComposite.conversionRate + conversionRateConfig = minimumComposite.conversionRateConfig + currency = minimumComposite.currency + dimensionalPriceConfiguration = + minimumComposite.dimensionalPriceConfiguration + externalPriceId = minimumComposite.externalPriceId + fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey + invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration + licenseTypeId = minimumComposite.licenseTypeId + metadata = minimumComposite.metadata + referenceId = minimumComposite.referenceId + additionalProperties = minimumComposite.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** Configuration for minimum_composite pricing */ + fun minimumCompositeConfig(minimumCompositeConfig: MinimumCompositeConfig) = + minimumCompositeConfig(JsonField.of(minimumCompositeConfig)) + + /** + * Sets [Builder.minimumCompositeConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCompositeConfig] with a well-typed + * [MinimumCompositeConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun minimumCompositeConfig( + minimumCompositeConfig: JsonField + ) = apply { this.minimumCompositeConfig = minimumCompositeConfig } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum_composite") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [MinimumComposite]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .minimumCompositeConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumComposite = + MinimumComposite( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("minimumCompositeConfig", minimumCompositeConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumComposite = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + minimumCompositeConfig().validate() + _modelType().let { + if (it != JsonValue.from("minimum_composite")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (minimumCompositeConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("minimum_composite")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for minimum_composite pricing */ + class MinimumCompositeConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val minimumAmount: JsonField, + private val prorated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("prorated") + @ExcludeMissing + prorated: JsonField = JsonMissing.of(), + ) : this(minimumAmount, prorated, mutableMapOf()) + + /** + * The minimum amount to apply + * + * @throws OrbInvalidDataException 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 minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * If true, subtotals from this price are prorated based on the service period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun prorated(): Optional = prorated.getOptional("prorated") + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [prorated]. + * + * Unlike [prorated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("prorated") + @ExcludeMissing + fun _prorated(): JsonField = prorated + + @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 + * [MinimumCompositeConfig]. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumCompositeConfig]. */ + class Builder internal constructor() { + + private var minimumAmount: JsonField? = null + private var prorated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(minimumCompositeConfig: MinimumCompositeConfig) = apply { + minimumAmount = minimumCompositeConfig.minimumAmount + prorated = minimumCompositeConfig.prorated + additionalProperties = + minimumCompositeConfig.additionalProperties.toMutableMap() + } + + /** The minimum amount to apply */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If true, subtotals from this price are prorated based on the service + * period + */ + fun prorated(prorated: Boolean) = prorated(JsonField.of(prorated)) + + /** + * Sets [Builder.prorated] to an arbitrary JSON value. + * + * You should usually call [Builder.prorated] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun prorated(prorated: JsonField) = apply { + this.prorated = prorated + } + + 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 [MinimumCompositeConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .minimumAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MinimumCompositeConfig = + MinimumCompositeConfig( + checkRequired("minimumAmount", minimumAmount), + prorated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MinimumCompositeConfig = apply { + if (validated) { + return@apply + } + + minimumAmount() + prorated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (minimumAmount.asKnown().isPresent) 1 else 0) + + (if (prorated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumCompositeConfig && + minimumAmount == other.minimumAmount && + prorated == other.prorated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(minimumAmount, prorated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumCompositeConfig{minimumAmount=$minimumAmount, prorated=$prorated, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinimumComposite && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + minimumCompositeConfig == other.minimumCompositeConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + minimumCompositeConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumComposite{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException 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 percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + licenseAllocations = percent.licenseAllocations.map { it.toMutableList() } + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException 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 percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @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 + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + 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 [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException 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 eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException 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 licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * 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 [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = + null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + licenseAllocations = + eventOutput.licenseAllocations.map { it.toMutableList() } + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + 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 } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .licenseAllocations() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + licenseAllocations().forEach { it.validate() } + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + 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 ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * 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 { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * 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) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + 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 OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("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 OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException 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 unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @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 + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + 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 [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException 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(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException 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 currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * 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 [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @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 + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = + licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] 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 currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + 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 [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + licenseAllocations, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + /** New plan price request body params. */ + @JsonDeserialize(using = InnerPrice.Deserializer::class) + @JsonSerialize(using = InnerPrice.Serializer::class) + class InnerPrice + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): InnerPrice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerPrice && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "InnerPrice{unit=$unit}" + tiered != null -> "InnerPrice{tiered=$tiered}" + bulk != null -> "InnerPrice{bulk=$bulk}" + bulkWithFilters != null -> "InnerPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "InnerPrice{package_=$package_}" + matrix != null -> "InnerPrice{matrix=$matrix}" + thresholdTotalAmount != null -> + "InnerPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "InnerPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "InnerPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "InnerPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "InnerPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "InnerPrice{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" + tieredWithProration != null -> + "InnerPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "InnerPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "InnerPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "InnerPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "InnerPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "InnerPrice{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "InnerPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "InnerPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "InnerPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "InnerPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + minimumComposite != null -> "InnerPrice{minimumComposite=$minimumComposite}" + percent != null -> "InnerPrice{percent=$percent}" + eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" + _json != null -> "InnerPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InnerPrice") + } + + companion object { + + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = InnerPrice(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + InnerPrice(bulkWithFilters = bulkWithFilters) + + @JvmStatic + fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + InnerPrice(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + InnerPrice(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + InnerPrice(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + InnerPrice(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = InnerPrice(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + InnerPrice(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + InnerPrice(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + InnerPrice(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + InnerPrice(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + InnerPrice(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + InnerPrice(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = InnerPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = InnerPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = InnerPrice(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + InnerPrice(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = InnerPrice(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = InnerPrice(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = InnerPrice(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = InnerPrice(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + InnerPrice(minimumComposite = minimumComposite) + + @JvmStatic fun ofPercent(percent: Percent) = InnerPrice(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [InnerPrice] to a value of type + * [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [InnerPrice] to a value of type [T]. + * + * An instance of [InnerPrice] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown InnerPrice: $json") + } + } + + internal class Deserializer : BaseDeserializer(InnerPrice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InnerPrice { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(unit = it, _json = json) + } ?: InnerPrice(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(tiered = it, _json = json) + } ?: InnerPrice(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(bulk = it, _json = json) + } ?: InnerPrice(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(bulkWithFilters = it, _json = json) + } ?: InnerPrice(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(package_ = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(matrix = it, _json = json) + } ?: InnerPrice(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(thresholdTotalAmount = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(tieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(groupedTiered = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(packageWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithPercent = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(tieredWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(bulkWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithProratedMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMinMaxThresholds = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedTieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(maxGroupTieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(scalableMatrixWithUnitPricing = it, _json = json) + } ?: InnerPrice(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(scalableMatrixWithTieredPricing = it, _json = json) + } ?: InnerPrice(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } + ?: InnerPrice(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(cumulativeGroupedAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(minimumComposite = it, _json = json) } + ?: InnerPrice(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(percent = it, _json = json) + } ?: InnerPrice(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(eventOutput = it, _json = json) + } ?: InnerPrice(_json = json) + } + } + + return InnerPrice(_json = json) + } + } + + internal class Serializer : BaseSerializer(InnerPrice::class) { + + override fun serialize( + value: InnerPrice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InnerPrice") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException 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 bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException 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 id of the item the price will be associated with. + * + * @throws OrbInvalidDataException 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 itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * 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 [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @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 [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + 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 [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException 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 filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException 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 tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @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 + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -5026,6 +75233,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -5049,6 +75257,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -5058,7 +75267,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -5081,6 +75290,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -5140,6 +75350,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5163,6 +75376,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -5322,6 +75536,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5491,6 +75713,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5566,6 +75798,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5590,6 +75823,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -6010,6 +76244,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6106,6 +76361,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6139,6 +76395,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -6178,6 +76435,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -6892,6 +77150,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -6915,6 +77174,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -6924,7 +77184,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -6948,6 +77208,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -7008,6 +77269,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7031,6 +77295,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -7192,6 +77457,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7361,6 +77634,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7438,6 +77721,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7465,6 +77749,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -7892,6 +78177,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7991,6 +78297,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -8024,6 +78331,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -8063,6 +78371,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -8685,6 +78994,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8708,6 +79018,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8717,7 +79028,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -8741,6 +79052,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8801,6 +79113,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8824,6 +79139,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8985,6 +79301,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9154,6 +79478,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9231,6 +79565,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9258,6 +79593,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -9685,6 +80021,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9784,6 +80141,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9817,6 +80175,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -9856,6 +80215,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -10485,6 +80845,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10508,6 +80869,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10517,7 +80879,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -10540,6 +80902,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10598,6 +80961,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10621,6 +80987,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10779,6 +81146,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10947,6 +81322,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11020,6 +81405,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11042,6 +81428,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -11460,6 +81847,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11556,6 +81964,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -11589,6 +81998,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -11626,6 +82036,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -12095,6 +82506,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12118,6 +82530,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12127,7 +82540,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -12150,6 +82563,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12208,6 +82622,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12231,6 +82648,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12390,6 +82808,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12558,6 +82984,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12631,6 +83067,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12653,6 +83090,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -13071,6 +83509,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13167,6 +83626,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13200,6 +83660,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13237,6 +83698,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13826,6 +84288,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -13849,6 +84312,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13858,7 +84322,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -13869,19 +84333,26 @@ private constructor( return other is Price && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Price{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "Price{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } class Adjustment diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt index efc13af59..1ce91374e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -1205,6 +1205,7 @@ private constructor( private val replacesPriceId: JsonField, private val unitConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -1281,6 +1282,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -1310,6 +1314,7 @@ private constructor( replacesPriceId, unitConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -1511,6 +1516,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -1764,6 +1778,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1846,6 +1869,7 @@ private constructor( private var unitConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1878,6 +1902,7 @@ private constructor( replacesPriceId = unitPrice.replacesPriceId unitConfig = unitPrice.unitConfig dimensionalPriceConfiguration = unitPrice.dimensionalPriceConfiguration + licenseType = unitPrice.licenseType additionalProperties = unitPrice.additionalProperties.toMutableMap() } @@ -2506,6 +2531,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2594,6 +2642,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("unitConfig", unitConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -2637,6 +2686,7 @@ private constructor( replacesPriceId() unitConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -2684,7 +2734,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3755,6 +3806,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3789,6 +4098,7 @@ private constructor( replacesPriceId == other.replacesPriceId && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -3822,6 +4132,7 @@ private constructor( replacesPriceId, unitConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -3829,7 +4140,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Tiered @@ -3863,6 +4174,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -3939,6 +4251,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -3968,6 +4283,7 @@ private constructor( replacesPriceId, tieredConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -4169,6 +4485,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -4423,6 +4748,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4505,6 +4839,7 @@ private constructor( private var tieredConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4537,6 +4872,7 @@ private constructor( replacesPriceId = tiered.replacesPriceId tieredConfig = tiered.tieredConfig dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + licenseType = tiered.licenseType additionalProperties = tiered.additionalProperties.toMutableMap() } @@ -5165,6 +5501,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5253,6 +5612,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredConfig", tieredConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -5296,6 +5656,7 @@ private constructor( replacesPriceId() tieredConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -5343,7 +5704,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6414,6 +6776,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6448,6 +7068,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -6481,6 +7102,7 @@ private constructor( replacesPriceId, tieredConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -6488,7 +7110,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Bulk @@ -6522,6 +7144,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -6598,6 +7221,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -6627,6 +7253,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -6828,6 +7455,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -7081,6 +7717,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7163,6 +7808,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7195,6 +7841,7 @@ private constructor( priceType = bulk.priceType replacesPriceId = bulk.replacesPriceId dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + licenseType = bulk.licenseType additionalProperties = bulk.additionalProperties.toMutableMap() } @@ -7823,6 +8470,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -7911,6 +8581,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -7954,6 +8625,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -8001,7 +8673,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -9072,6 +9745,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9106,6 +10037,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -9139,6 +10071,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -9146,7 +10079,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class BulkWithFilters @@ -9180,6 +10113,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -9256,6 +10190,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -9285,6 +10222,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -9487,6 +10425,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -9741,6 +10688,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -9823,6 +10779,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9856,6 +10813,7 @@ private constructor( priceType = bulkWithFilters.priceType replacesPriceId = bulkWithFilters.replacesPriceId dimensionalPriceConfiguration = bulkWithFilters.dimensionalPriceConfiguration + licenseType = bulkWithFilters.licenseType additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -10486,6 +11444,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10574,6 +11555,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -10617,6 +11599,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -10664,7 +11647,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -12421,6 +13405,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12455,6 +13697,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -12488,6 +13731,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -12495,7 +13739,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Package @@ -12529,6 +13773,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -12605,6 +13850,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -12634,6 +13882,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -12835,6 +14084,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -13089,6 +14347,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -13171,6 +14438,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13203,6 +14471,7 @@ private constructor( priceType = package_.priceType replacesPriceId = package_.replacesPriceId dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + licenseType = package_.licenseType additionalProperties = package_.additionalProperties.toMutableMap() } @@ -13832,6 +15101,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -13920,6 +15212,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -13963,6 +15256,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -14010,7 +15304,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -15081,6 +16376,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15115,6 +16668,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -15148,6 +16702,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -15155,7 +16710,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Matrix @@ -15189,6 +16744,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -15265,6 +16821,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -15294,6 +16853,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -15495,6 +17055,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -15749,6 +17318,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -15831,6 +17409,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15863,6 +17442,7 @@ private constructor( priceType = matrix.priceType replacesPriceId = matrix.replacesPriceId dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + licenseType = matrix.licenseType additionalProperties = matrix.additionalProperties.toMutableMap() } @@ -16491,6 +18071,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -16579,6 +18182,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -16622,6 +18226,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -16669,7 +18274,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -17740,6 +19346,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17774,6 +19638,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -17807,6 +19672,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -17814,7 +19680,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ThresholdTotalAmount @@ -17848,6 +19714,7 @@ private constructor( private val replacesPriceId: JsonField, private val thresholdTotalAmountConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -17924,6 +19791,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -17953,6 +19823,7 @@ private constructor( replacesPriceId, thresholdTotalAmountConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -18155,6 +20026,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -18410,6 +20290,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -18492,6 +20381,7 @@ private constructor( private var thresholdTotalAmountConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18525,6 +20415,7 @@ private constructor( replacesPriceId = thresholdTotalAmount.replacesPriceId thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig dimensionalPriceConfiguration = thresholdTotalAmount.dimensionalPriceConfiguration + licenseType = thresholdTotalAmount.licenseType additionalProperties = thresholdTotalAmount.additionalProperties.toMutableMap() } @@ -19154,6 +21045,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -19242,6 +21156,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -19285,6 +21200,7 @@ private constructor( replacesPriceId() thresholdTotalAmountConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -19332,7 +21248,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -20865,6 +22782,264 @@ private constructor( "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20899,6 +23074,7 @@ private constructor( replacesPriceId == other.replacesPriceId && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -20932,6 +23108,7 @@ private constructor( replacesPriceId, thresholdTotalAmountConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -20939,7 +23116,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredPackage @@ -20973,6 +23150,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredPackageConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -21049,6 +23227,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -21078,6 +23259,7 @@ private constructor( replacesPriceId, tieredPackageConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -21280,6 +23462,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -21534,6 +23725,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -21616,6 +23816,7 @@ private constructor( private var tieredPackageConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21649,6 +23850,7 @@ private constructor( replacesPriceId = tieredPackage.replacesPriceId tieredPackageConfig = tieredPackage.tieredPackageConfig dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + licenseType = tieredPackage.licenseType additionalProperties = tieredPackage.additionalProperties.toMutableMap() } @@ -22278,6 +24480,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -22366,6 +24591,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredPackageConfig", tieredPackageConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -22409,6 +24635,7 @@ private constructor( replacesPriceId() tieredPackageConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -22456,7 +24683,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -23977,6 +26205,264 @@ private constructor( "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24011,6 +26497,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -24044,6 +26531,7 @@ private constructor( replacesPriceId, tieredPackageConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -24051,7 +26539,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredWithMinimum @@ -24085,6 +26573,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -24161,6 +26650,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -24190,6 +26682,7 @@ private constructor( replacesPriceId, tieredWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -24392,6 +26885,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -24646,6 +27148,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -24728,6 +27239,7 @@ private constructor( private var tieredWithMinimumConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24761,6 +27273,7 @@ private constructor( replacesPriceId = tieredWithMinimum.replacesPriceId tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig dimensionalPriceConfiguration = tieredWithMinimum.dimensionalPriceConfiguration + licenseType = tieredWithMinimum.licenseType additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } @@ -25390,6 +27903,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -25478,6 +28014,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -25521,6 +28058,7 @@ private constructor( replacesPriceId() tieredWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -25568,7 +28106,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -27173,6 +29712,264 @@ private constructor( "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27207,6 +30004,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -27240,6 +30038,7 @@ private constructor( replacesPriceId, tieredWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -27247,7 +30046,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedTiered @@ -27281,6 +30080,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -27357,6 +30157,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -27386,6 +30189,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -27588,6 +30392,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -27842,6 +30655,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -27924,6 +30746,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -27957,6 +30780,7 @@ private constructor( priceType = groupedTiered.priceType replacesPriceId = groupedTiered.replacesPriceId dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + licenseType = groupedTiered.licenseType additionalProperties = groupedTiered.additionalProperties.toMutableMap() } @@ -28586,6 +31410,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -28674,6 +31521,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -28717,6 +31565,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -28764,7 +31613,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -30285,6 +33135,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30319,6 +33427,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -30352,6 +33461,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -30359,7 +33469,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredPackageWithMinimum @@ -30393,6 +33503,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredPackageWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -30470,6 +33581,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -30499,6 +33613,7 @@ private constructor( replacesPriceId, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -30701,6 +33816,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -30956,6 +34080,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -31039,6 +34172,7 @@ private constructor( null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -31074,6 +34208,7 @@ private constructor( tieredPackageWithMinimum.tieredPackageWithMinimumConfig dimensionalPriceConfiguration = tieredPackageWithMinimum.dimensionalPriceConfiguration + licenseType = tieredPackageWithMinimum.licenseType additionalProperties = tieredPackageWithMinimum.additionalProperties.toMutableMap() } @@ -31704,6 +34839,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -31792,6 +34950,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -31835,6 +34994,7 @@ private constructor( replacesPriceId() tieredPackageWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -31884,7 +35044,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -33444,6 +36605,264 @@ private constructor( "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33478,6 +36897,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -33511,6 +36931,7 @@ private constructor( replacesPriceId, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -33518,7 +36939,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class PackageWithAllocation @@ -33552,6 +36973,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -33628,6 +37050,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -33657,6 +37082,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -33859,6 +37285,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -34114,6 +37549,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -34196,6 +37640,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -34229,6 +37674,7 @@ private constructor( priceType = packageWithAllocation.priceType replacesPriceId = packageWithAllocation.replacesPriceId dimensionalPriceConfiguration = packageWithAllocation.dimensionalPriceConfiguration + licenseType = packageWithAllocation.licenseType additionalProperties = packageWithAllocation.additionalProperties.toMutableMap() } @@ -34859,6 +38305,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -34947,6 +38416,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -34990,6 +38460,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -35037,7 +38508,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -36368,6 +39840,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36402,6 +40132,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -36435,6 +40166,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -36442,7 +40174,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class UnitWithPercent @@ -36476,6 +40208,7 @@ private constructor( private val replacesPriceId: JsonField, private val unitWithPercentConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -36552,6 +40285,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -36581,6 +40317,7 @@ private constructor( replacesPriceId, unitWithPercentConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -36783,6 +40520,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -37037,6 +40783,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -37119,6 +40874,7 @@ private constructor( private var unitWithPercentConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37152,6 +40908,7 @@ private constructor( replacesPriceId = unitWithPercent.replacesPriceId unitWithPercentConfig = unitWithPercent.unitWithPercentConfig dimensionalPriceConfiguration = unitWithPercent.dimensionalPriceConfiguration + licenseType = unitWithPercent.licenseType additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } @@ -37782,6 +41539,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -37870,6 +41650,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("unitWithPercentConfig", unitWithPercentConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -37913,6 +41694,7 @@ private constructor( replacesPriceId() unitWithPercentConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -37960,7 +41742,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -39247,6 +43030,264 @@ private constructor( "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39281,6 +43322,7 @@ private constructor( replacesPriceId == other.replacesPriceId && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -39314,6 +43356,7 @@ private constructor( replacesPriceId, unitWithPercentConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -39321,7 +43364,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MatrixWithAllocation @@ -39355,6 +43398,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -39431,6 +43475,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -39460,6 +43507,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -39662,6 +43710,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -39917,6 +43974,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -39999,6 +44065,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -40032,6 +44099,7 @@ private constructor( priceType = matrixWithAllocation.priceType replacesPriceId = matrixWithAllocation.replacesPriceId dimensionalPriceConfiguration = matrixWithAllocation.dimensionalPriceConfiguration + licenseType = matrixWithAllocation.licenseType additionalProperties = matrixWithAllocation.additionalProperties.toMutableMap() } @@ -40661,6 +44729,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -40749,6 +44840,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -40792,6 +44884,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -40839,7 +44932,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -41910,6 +46004,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41944,6 +46296,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -41977,6 +46330,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -41984,7 +46338,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -42018,6 +46372,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -42094,6 +46449,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -42123,6 +46481,7 @@ private constructor( replacesPriceId, tieredWithProrationConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -42325,6 +46684,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -42580,6 +46948,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -42662,6 +47039,7 @@ private constructor( private var tieredWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -42695,6 +47073,7 @@ private constructor( replacesPriceId = tieredWithProration.replacesPriceId tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig dimensionalPriceConfiguration = tieredWithProration.dimensionalPriceConfiguration + licenseType = tieredWithProration.licenseType additionalProperties = tieredWithProration.additionalProperties.toMutableMap() } @@ -43324,6 +47703,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -43412,6 +47814,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -43455,6 +47858,7 @@ private constructor( replacesPriceId() tieredWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -43502,7 +47906,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -44982,6 +49387,264 @@ private constructor( "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -45016,6 +49679,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -45049,6 +49713,7 @@ private constructor( replacesPriceId, tieredWithProrationConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -45056,7 +49721,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class UnitWithProration @@ -45090,6 +49755,7 @@ private constructor( private val replacesPriceId: JsonField, private val unitWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -45166,6 +49832,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -45195,6 +49864,7 @@ private constructor( replacesPriceId, unitWithProrationConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -45397,6 +50067,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -45651,6 +50330,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -45733,6 +50421,7 @@ private constructor( private var unitWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -45766,6 +50455,7 @@ private constructor( replacesPriceId = unitWithProration.replacesPriceId unitWithProrationConfig = unitWithProration.unitWithProrationConfig dimensionalPriceConfiguration = unitWithProration.dimensionalPriceConfiguration + licenseType = unitWithProration.licenseType additionalProperties = unitWithProration.additionalProperties.toMutableMap() } @@ -46395,6 +51085,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -46483,6 +51196,7 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("unitWithProrationConfig", unitWithProrationConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -46526,6 +51240,7 @@ private constructor( replacesPriceId() unitWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -46573,7 +51288,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -47818,6 +52534,264 @@ private constructor( "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -47852,6 +52826,7 @@ private constructor( replacesPriceId == other.replacesPriceId && unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -47885,6 +52860,7 @@ private constructor( replacesPriceId, unitWithProrationConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -47892,7 +52868,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedAllocation @@ -47926,6 +52902,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -48002,6 +52979,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -48031,6 +53011,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -48233,6 +53214,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -48487,6 +53477,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -48569,6 +53568,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -48602,6 +53602,7 @@ private constructor( priceType = groupedAllocation.priceType replacesPriceId = groupedAllocation.replacesPriceId dimensionalPriceConfiguration = groupedAllocation.dimensionalPriceConfiguration + licenseType = groupedAllocation.licenseType additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } @@ -49231,6 +54232,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -49319,6 +54343,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -49362,6 +54387,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -49409,7 +54435,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -50748,6 +55775,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -50782,6 +56067,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -50815,6 +56101,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -50822,7 +56109,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class BulkWithProration @@ -50856,6 +56143,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -50932,6 +56220,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -50961,6 +56252,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -51163,6 +56455,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -51417,6 +56718,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -51499,6 +56809,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -51532,6 +56843,7 @@ private constructor( priceType = bulkWithProration.priceType replacesPriceId = bulkWithProration.replacesPriceId dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration + licenseType = bulkWithProration.licenseType additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } @@ -52161,6 +57473,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -52249,6 +57584,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -52292,6 +57628,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -52339,7 +57676,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -53820,6 +59158,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -53854,6 +59450,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -53887,6 +59484,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -53894,7 +59492,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithProratedMinimum @@ -53928,6 +59526,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -54005,6 +59604,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -54034,6 +59636,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -54236,6 +59839,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -54491,6 +60103,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -54576,6 +60197,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -54611,6 +60233,7 @@ private constructor( replacesPriceId = groupedWithProratedMinimum.replacesPriceId dimensionalPriceConfiguration = groupedWithProratedMinimum.dimensionalPriceConfiguration + licenseType = groupedWithProratedMinimum.licenseType additionalProperties = groupedWithProratedMinimum.additionalProperties.toMutableMap() } @@ -55242,6 +60865,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -55333,6 +60979,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -55376,6 +61023,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -55425,7 +61073,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -56756,6 +62405,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -56790,6 +62697,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -56823,6 +62731,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -56830,7 +62739,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithMeteredMinimum @@ -56864,6 +62773,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -56941,6 +62851,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -56970,6 +62883,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -57172,6 +63086,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -57427,6 +63350,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -57512,6 +63444,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -57547,6 +63480,7 @@ private constructor( replacesPriceId = groupedWithMeteredMinimum.replacesPriceId dimensionalPriceConfiguration = groupedWithMeteredMinimum.dimensionalPriceConfiguration + licenseType = groupedWithMeteredMinimum.licenseType additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() } @@ -58177,6 +64111,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -58268,6 +64225,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -58311,6 +64269,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -58360,7 +64319,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -60322,6 +66282,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -60356,6 +66574,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -60389,6 +66608,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -60396,7 +66616,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -60430,6 +66650,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -60507,6 +66728,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -60536,6 +66760,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -60738,6 +66963,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -60993,6 +67227,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -61078,6 +67321,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -61114,6 +67358,7 @@ private constructor( replacesPriceId = groupedWithMinMaxThresholds.replacesPriceId dimensionalPriceConfiguration = groupedWithMinMaxThresholds.dimensionalPriceConfiguration + licenseType = groupedWithMinMaxThresholds.licenseType additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } @@ -61745,6 +67990,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -61836,6 +68104,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -61879,6 +68148,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -61928,7 +68198,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63321,6 +69592,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -63355,6 +69884,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -63388,6 +69918,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -63395,7 +69926,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MatrixWithDisplayName @@ -63429,6 +69960,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -63505,6 +70037,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -63534,6 +70069,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -63736,6 +70272,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -63991,6 +70536,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -64073,6 +70627,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -64106,6 +70661,7 @@ private constructor( priceType = matrixWithDisplayName.priceType replacesPriceId = matrixWithDisplayName.replacesPriceId dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration + licenseType = matrixWithDisplayName.licenseType additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() } @@ -64736,6 +71292,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -64824,6 +71403,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -64867,6 +71447,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -64914,7 +71495,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -66486,6 +73068,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -66520,6 +73360,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -66553,6 +73394,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -66560,7 +73402,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedTieredPackage @@ -66594,6 +73436,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -66670,6 +73513,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -66699,6 +73545,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -66901,6 +73748,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -67156,6 +74012,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -67238,6 +74103,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -67271,6 +74137,7 @@ private constructor( priceType = groupedTieredPackage.priceType replacesPriceId = groupedTieredPackage.replacesPriceId dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration + licenseType = groupedTieredPackage.licenseType additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() } @@ -67900,6 +74767,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -67988,6 +74878,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -68031,6 +74922,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -68078,7 +74970,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -69642,6 +76535,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -69676,6 +76827,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -69709,6 +76861,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -69716,7 +76869,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MaxGroupTieredPackage @@ -69750,6 +76903,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -69826,6 +76980,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -69855,6 +77012,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -70057,6 +77215,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -70312,6 +77479,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -70394,6 +77570,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -70427,6 +77604,7 @@ private constructor( priceType = maxGroupTieredPackage.priceType replacesPriceId = maxGroupTieredPackage.replacesPriceId dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration + licenseType = maxGroupTieredPackage.licenseType additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() } @@ -71057,6 +78235,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -71145,6 +78346,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -71188,6 +78390,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -71235,7 +78438,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -72802,6 +80006,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -72836,6 +80298,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -72869,6 +80332,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -72876,7 +80340,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ScalableMatrixWithUnitPricing @@ -72911,6 +80375,7 @@ private constructor( private val scalableMatrixWithUnitPricingConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -72988,6 +80453,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -73017,6 +80485,7 @@ private constructor( replacesPriceId, scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -73221,6 +80690,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -73476,6 +80954,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -73561,6 +81048,7 @@ private constructor( null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -73601,6 +81089,7 @@ private constructor( scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig dimensionalPriceConfiguration = scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + licenseType = scalableMatrixWithUnitPricing.licenseType additionalProperties = scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() } @@ -74237,6 +81726,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -74328,6 +81840,7 @@ private constructor( scalableMatrixWithUnitPricingConfig, ), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -74371,6 +81884,7 @@ private constructor( replacesPriceId() scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -74420,7 +81934,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -75498,6 +83013,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -75514,6 +83030,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @@ -75524,6 +83043,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -75557,6 +83077,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -75604,6 +83132,16 @@ private constructor( @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -75656,6 +83194,7 @@ private constructor( private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -75670,6 +83209,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -75732,6 +83272,25 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -75818,6 +83377,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -75834,6 +83394,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -75859,6 +83420,7 @@ private constructor( (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (prorate.asKnown().isPresent) 1 else 0) + (if (secondDimension.asKnown().isPresent) 1 else 0) @@ -76143,6 +83705,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -76153,6 +83716,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -76162,7 +83726,265 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -76199,6 +84021,7 @@ private constructor( replacesPriceId == other.replacesPriceId && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -76232,6 +84055,7 @@ private constructor( replacesPriceId, scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -76239,7 +84063,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ScalableMatrixWithTieredPricing @@ -76274,6 +84098,7 @@ private constructor( private val scalableMatrixWithTieredPricingConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -76352,6 +84177,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -76381,6 +84209,7 @@ private constructor( replacesPriceId, scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -76585,6 +84414,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -76840,6 +84678,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -76925,6 +84772,7 @@ private constructor( null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -76965,6 +84813,7 @@ private constructor( scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig dimensionalPriceConfiguration = scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + licenseType = scalableMatrixWithTieredPricing.licenseType additionalProperties = scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } @@ -77602,6 +85451,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -77693,6 +85565,7 @@ private constructor( scalableMatrixWithTieredPricingConfig, ), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -77736,6 +85609,7 @@ private constructor( replacesPriceId() scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -77785,7 +85659,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -79698,6 +87573,264 @@ private constructor( "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -79733,6 +87866,7 @@ private constructor( scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -79766,6 +87900,7 @@ private constructor( replacesPriceId, scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -79773,7 +87908,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class CumulativeGroupedBulk @@ -79807,6 +87942,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -79883,6 +88019,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -79912,6 +88051,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -80114,6 +88254,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -80369,6 +88518,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -80451,6 +88609,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -80484,6 +88643,7 @@ private constructor( priceType = cumulativeGroupedBulk.priceType replacesPriceId = cumulativeGroupedBulk.replacesPriceId dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration + licenseType = cumulativeGroupedBulk.licenseType additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() } @@ -81114,6 +89274,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -81202,6 +89385,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -81245,6 +89429,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -81292,7 +89477,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -82857,6 +91043,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -82891,6 +91335,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -82924,6 +91369,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -82931,7 +91377,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -82965,6 +91411,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -83042,6 +91489,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -83071,6 +91521,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -83273,6 +91724,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -83528,6 +91988,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -83613,6 +92082,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -83649,6 +92119,7 @@ private constructor( replacesPriceId = cumulativeGroupedAllocation.replacesPriceId dimensionalPriceConfiguration = cumulativeGroupedAllocation.dimensionalPriceConfiguration + licenseType = cumulativeGroupedAllocation.licenseType additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() } @@ -84280,6 +92751,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -84371,6 +92865,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -84414,6 +92909,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -84463,7 +92959,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -85672,20 +94169,404 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @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 USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] 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 { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] 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) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } + id() + groupingKey() + name() validated = true } @@ -85705,156 +94586,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @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 USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] 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 { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] 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) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - 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 OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $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 OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 PriceType && value == other.value + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int = hashCode - override fun toString() = value.toString() + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -85891,6 +94646,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -85924,6 +94680,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -85931,7 +94688,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MinimumComposite @@ -85965,6 +94722,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -86041,6 +94799,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -86070,6 +94831,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -86272,6 +95034,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -86526,6 +95297,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -86608,6 +95388,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -86641,6 +95422,7 @@ private constructor( priceType = minimumComposite.priceType replacesPriceId = minimumComposite.replacesPriceId dimensionalPriceConfiguration = minimumComposite.dimensionalPriceConfiguration + licenseType = minimumComposite.licenseType additionalProperties = minimumComposite.additionalProperties.toMutableMap() } @@ -87271,6 +96053,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -87359,6 +96164,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -87402,6 +96208,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -87449,7 +96256,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -88736,6 +97544,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88770,6 +97836,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -88803,6 +97870,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -88810,7 +97878,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MinimumComposite{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MinimumComposite{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Percent @@ -88844,6 +97912,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -88920,6 +97989,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -88949,6 +98021,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -89150,6 +98223,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -89404,6 +98486,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -89486,6 +98577,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -89518,6 +98610,7 @@ private constructor( priceType = percent.priceType replacesPriceId = percent.replacesPriceId dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + licenseType = percent.licenseType additionalProperties = percent.additionalProperties.toMutableMap() } @@ -90147,6 +99240,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -90235,6 +99351,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -90278,6 +99395,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -90325,7 +99443,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -91364,32 +100483,417 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(percent, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + class PriceType @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 USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] 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 { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] 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) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + 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 OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $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 OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .percent() + * .id() + * .groupingKey() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - percent() + id() + groupingKey() + name() validated = true } @@ -91407,159 +100911,32 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(percent, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" - } - - class PriceType @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 USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] 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 { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] 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) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - 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 OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $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 OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - 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 PriceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -91596,6 +100973,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -91629,6 +101007,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -91636,7 +101015,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class EventOutput @@ -91670,6 +101049,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -91746,6 +101126,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -91775,6 +101158,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -91977,6 +101361,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -92231,6 +101624,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -92313,6 +101715,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -92345,6 +101748,7 @@ private constructor( priceType = eventOutput.priceType replacesPriceId = eventOutput.replacesPriceId dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + licenseType = eventOutput.licenseType additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -92974,6 +102378,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -93062,6 +102489,7 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } @@ -93105,6 +102533,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -93152,7 +102581,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -94506,6 +103936,264 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException 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 id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException 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 groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException 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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94540,6 +104228,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -94573,6 +104262,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -94580,6 +104270,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index 33805bc5d..4fa8d654e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -1654,6 +1654,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -1707,6 +1708,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -1727,6 +1731,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -1881,6 +1886,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -2033,6 +2046,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -2095,6 +2118,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2116,6 +2140,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -2516,6 +2541,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -2591,6 +2635,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -2623,6 +2668,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -2659,6 +2705,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -3642,6 +3689,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -3664,6 +3712,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -3672,7 +3721,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -3695,6 +3744,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -3749,6 +3799,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3769,6 +3822,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -3925,6 +3979,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -4078,6 +4140,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -4143,6 +4215,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4169,6 +4242,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() @@ -4575,6 +4649,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -4653,6 +4746,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -4685,6 +4779,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -4723,6 +4818,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -5334,6 +5430,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -5356,6 +5453,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -5364,7 +5462,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -5387,6 +5485,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -5441,6 +5540,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5461,6 +5563,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -5617,6 +5720,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5770,6 +5881,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5835,6 +5956,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5861,6 +5983,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() @@ -6267,6 +6390,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -6345,6 +6487,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -6377,6 +6520,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -6415,6 +6559,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -7034,6 +7179,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -7056,6 +7202,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -7064,7 +7211,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -7086,6 +7233,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -7139,6 +7287,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7159,6 +7310,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -7312,6 +7464,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7464,6 +7624,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7526,6 +7696,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7547,6 +7718,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -7946,6 +8118,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8021,6 +8212,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -8053,6 +8245,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -8089,6 +8282,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8546,6 +8740,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8568,6 +8763,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8576,7 +8772,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -8598,6 +8794,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8651,6 +8848,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8671,6 +8871,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8825,6 +9026,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8977,6 +9186,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9039,6 +9258,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9060,6 +9280,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -9459,6 +9680,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9534,6 +9774,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9566,6 +9807,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -9602,6 +9844,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -10176,6 +10419,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -10198,6 +10442,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -10206,7 +10451,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index d92a665b7..1d535d053 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -817,6 +817,7 @@ private constructor( private val externalPriceId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val price: JsonField, private val priceId: JsonField, private val additionalProperties: MutableMap, @@ -831,9 +832,20 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, filter, groupingKeys, price, priceId, mutableMapOf()) + ) : this( + externalPriceId, + filter, + groupingKeys, + metricParameterOverrides, + price, + priceId, + mutableMapOf(), + ) /** * The external ID of a price to evaluate that exists in your Orb account. @@ -862,6 +874,16 @@ private constructor( */ fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * New floating price request body params. * @@ -905,6 +927,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [price]. * @@ -943,6 +976,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -952,6 +987,7 @@ private constructor( externalPriceId = priceEvaluation.externalPriceId filter = priceEvaluation.filter groupingKeys = priceEvaluation.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = priceEvaluation.metricParameterOverrides price = priceEvaluation.price priceId = priceEvaluation.priceId additionalProperties = priceEvaluation.additionalProperties.toMutableMap() @@ -1024,6 +1060,32 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) @@ -1243,6 +1305,7 @@ private constructor( externalPriceId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, price, priceId, additionalProperties.toMutableMap(), @@ -1259,6 +1322,7 @@ private constructor( externalPriceId() filter() groupingKeys() + metricParameterOverrides().ifPresent { it.validate() } price().ifPresent { it.validate() } priceId() validated = true @@ -1283,9 +1347,123 @@ private constructor( (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (filter.asKnown().isPresent) 1 else 0) + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -2631,6 +2809,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -2688,6 +2867,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -2708,6 +2890,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -2866,6 +3049,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -3026,6 +3217,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3090,6 +3291,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3112,6 +3314,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -3523,6 +3726,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -3598,6 +3822,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -3630,6 +3855,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -3666,6 +3892,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -4662,6 +4889,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -4684,6 +4912,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -4692,7 +4921,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -4716,6 +4945,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -4775,6 +5005,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -4795,6 +5028,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -4955,6 +5189,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5115,6 +5357,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5183,6 +5435,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5209,6 +5462,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() @@ -5629,6 +5883,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -5707,6 +5982,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -5739,6 +6015,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -5777,6 +6054,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -6398,6 +6676,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6420,6 +6699,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6428,7 +6708,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -6452,6 +6732,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -6511,6 +6792,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6531,6 +6815,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -6691,6 +6976,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -6851,6 +7144,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6919,6 +7222,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6945,6 +7249,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() @@ -7365,6 +7670,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7443,6 +7769,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -7475,6 +7802,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -7513,6 +7841,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8141,6 +8470,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8163,6 +8493,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8171,7 +8502,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -8194,6 +8525,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8251,6 +8583,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8271,6 +8606,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8428,6 +8764,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8587,6 +8931,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8651,6 +9005,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8672,6 +9027,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -9083,6 +9439,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9158,6 +9535,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9190,6 +9568,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -9226,6 +9605,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9694,6 +10074,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -9716,6 +10097,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -9724,7 +10106,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -9747,6 +10129,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -9804,6 +10187,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -9824,6 +10210,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -9982,6 +10369,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10141,6 +10536,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10205,6 +10610,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10226,6 +10632,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -10637,6 +11044,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10712,6 +11140,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -10744,6 +11173,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -10780,6 +11210,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -11368,6 +11799,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -11390,6 +11822,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -11398,7 +11831,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } @@ -11411,6 +11844,7 @@ private constructor( externalPriceId == other.externalPriceId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties @@ -11421,6 +11855,7 @@ private constructor( externalPriceId, filter, groupingKeys, + metricParameterOverrides, price, priceId, additionalProperties, @@ -11430,7 +11865,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt index 138089286..80cce7318 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt @@ -105,6 +105,16 @@ private constructor( */ fun groupingKeys(): Optional> = body.groupingKeys() + /** + * Optional overrides for parameterized billable metric parameters. If the metric has parameter + * definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + body.metricParameterOverrides() + /** * Returns the raw JSON value of [timeframeEnd]. * @@ -148,6 +158,15 @@ private constructor( */ fun _groupingKeys(): JsonField> = body._groupingKeys() + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _metricParameterOverrides(): JsonField = + body._metricParameterOverrides() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -316,6 +335,32 @@ private constructor( */ fun addGroupingKey(groupingKey: String) = apply { body.addGroupingKey(groupingKey) } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = apply { + body.metricParameterOverrides(metricParameterOverrides) + } + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides(metricParameterOverrides: Optional) = + metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { body.metricParameterOverrides(metricParameterOverrides) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -476,6 +521,7 @@ private constructor( private val externalCustomerId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val additionalProperties: MutableMap, ) { @@ -497,6 +543,9 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), ) : this( timeframeEnd, timeframeStart, @@ -504,6 +553,7 @@ private constructor( externalCustomerId, filter, groupingKeys, + metricParameterOverrides, mutableMapOf(), ) @@ -559,6 +609,16 @@ private constructor( */ fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * Returns the raw JSON value of [timeframeEnd]. * @@ -615,6 +675,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -650,6 +721,8 @@ private constructor( private var externalCustomerId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -660,6 +733,7 @@ private constructor( externalCustomerId = body.externalCustomerId filter = body.filter groupingKeys = body.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = body.metricParameterOverrides additionalProperties = body.additionalProperties.toMutableMap() } @@ -778,6 +852,32 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -818,6 +918,7 @@ private constructor( externalCustomerId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, additionalProperties.toMutableMap(), ) } @@ -835,6 +936,7 @@ private constructor( externalCustomerId() filter() groupingKeys() + metricParameterOverrides().ifPresent { it.validate() } validated = true } @@ -859,7 +961,8 @@ private constructor( (if (customerId.asKnown().isPresent) 1 else 0) + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + (if (filter.asKnown().isPresent) 1 else 0) + - (groupingKeys.asKnown().getOrNull()?.size ?: 0) + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -873,6 +976,7 @@ private constructor( externalCustomerId == other.externalCustomerId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && additionalProperties == other.additionalProperties } @@ -884,6 +988,7 @@ private constructor( externalCustomerId, filter, groupingKeys, + metricParameterOverrides, additionalProperties, ) } @@ -891,7 +996,115 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, customerId=$customerId, externalCustomerId=$externalCustomerId, filter=$filter, groupingKeys=$groupingKeys, additionalProperties=$additionalProperties}" + "Body{timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, customerId=$customerId, externalCustomerId=$externalCustomerId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, additionalProperties=$additionalProperties}" + } + + /** + * Optional overrides for parameterized billable metric parameters. If the metric has parameter + * definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index 21999d6ba..4a46c25d7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -1367,6 +1367,7 @@ private constructor( private val externalPriceId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val price: JsonField, private val priceId: JsonField, private val additionalProperties: MutableMap, @@ -1381,9 +1382,20 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, filter, groupingKeys, price, priceId, mutableMapOf()) + ) : this( + externalPriceId, + filter, + groupingKeys, + metricParameterOverrides, + price, + priceId, + mutableMapOf(), + ) /** * The external ID of a price to evaluate that exists in your Orb account. @@ -1412,6 +1424,16 @@ private constructor( */ fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * New floating price request body params. * @@ -1455,6 +1477,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [price]. * @@ -1493,6 +1526,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1502,6 +1537,7 @@ private constructor( externalPriceId = priceEvaluation.externalPriceId filter = priceEvaluation.filter groupingKeys = priceEvaluation.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = priceEvaluation.metricParameterOverrides price = priceEvaluation.price priceId = priceEvaluation.priceId additionalProperties = priceEvaluation.additionalProperties.toMutableMap() @@ -1574,6 +1610,32 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) @@ -1793,6 +1855,7 @@ private constructor( externalPriceId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, price, priceId, additionalProperties.toMutableMap(), @@ -1809,6 +1872,7 @@ private constructor( externalPriceId() filter() groupingKeys() + metricParameterOverrides().ifPresent { it.validate() } price().ifPresent { it.validate() } priceId() validated = true @@ -1833,9 +1897,123 @@ private constructor( (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (filter.asKnown().isPresent) 1 else 0) + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -3181,6 +3359,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -3238,6 +3417,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3258,6 +3440,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -3416,6 +3599,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -3576,6 +3767,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3640,6 +3841,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3662,6 +3864,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -4073,6 +4276,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -4148,6 +4372,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -4180,6 +4405,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -4216,6 +4442,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -5212,6 +5439,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -5234,6 +5462,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -5242,7 +5471,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -5266,6 +5495,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -5325,6 +5555,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5345,6 +5578,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -5505,6 +5739,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5665,6 +5907,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5733,6 +5985,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5759,6 +6012,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() @@ -6179,6 +6433,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6257,6 +6532,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -6289,6 +6565,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -6327,6 +6604,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -6948,6 +7226,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6970,6 +7249,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6978,7 +7258,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -7002,6 +7282,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -7061,6 +7342,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7081,6 +7365,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -7241,6 +7526,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7401,6 +7694,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7469,6 +7772,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7495,6 +7799,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() @@ -7915,6 +8220,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7993,6 +8319,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -8025,6 +8352,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -8063,6 +8391,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8691,6 +9020,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8713,6 +9043,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8721,7 +9052,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -8744,6 +9075,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8801,6 +9133,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8821,6 +9156,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8978,6 +9314,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9137,6 +9481,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9201,6 +9555,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9222,6 +9577,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -9633,6 +9989,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9708,6 +10085,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9740,6 +10118,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -9776,6 +10155,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -10244,6 +10624,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -10266,6 +10647,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -10274,7 +10656,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -10297,6 +10679,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -10354,6 +10737,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10374,6 +10760,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -10532,6 +10919,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10691,6 +11086,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10755,6 +11160,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10776,6 +11182,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -11187,6 +11594,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11262,6 +11690,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -11294,6 +11723,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -11330,6 +11760,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -11918,6 +12349,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -11940,6 +12372,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -11948,7 +12381,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } @@ -11961,6 +12394,7 @@ private constructor( externalPriceId == other.externalPriceId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties @@ -11971,6 +12405,7 @@ private constructor( externalPriceId, filter, groupingKeys, + metricParameterOverrides, price, priceId, additionalProperties, @@ -11980,7 +12415,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 370d06454..3b0178ed2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -38,6 +38,7 @@ private constructor( private val price: JsonField, private val startDate: JsonField, private val usageCustomerIds: JsonField>, + private val metricParameterOverrides: JsonField, private val additionalProperties: MutableMap, ) { @@ -70,6 +71,9 @@ private constructor( @JsonProperty("usage_customer_ids") @ExcludeMissing usageCustomerIds: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), ) : this( id, billingCycleDay, @@ -82,6 +86,7 @@ private constructor( price, startDate, usageCustomerIds, + metricParameterOverrides, mutableMapOf(), ) @@ -192,6 +197,16 @@ private constructor( fun usageCustomerIds(): Optional> = usageCustomerIds.getOptional("usage_customer_ids") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, values + * are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * Returns the raw JSON value of [id]. * @@ -288,6 +303,16 @@ private constructor( @ExcludeMissing fun _usageCustomerIds(): JsonField> = usageCustomerIds + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = metricParameterOverrides + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -339,6 +364,7 @@ private constructor( private var price: JsonField? = null private var startDate: JsonField? = null private var usageCustomerIds: JsonField>? = null + private var metricParameterOverrides: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -355,6 +381,7 @@ private constructor( price = priceInterval.price startDate = priceInterval.startDate usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } + metricParameterOverrides = priceInterval.metricParameterOverrides additionalProperties = priceInterval.additionalProperties.toMutableMap() } @@ -744,6 +771,31 @@ private constructor( } } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides(metricParameterOverrides: Optional) = + metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -800,6 +852,7 @@ private constructor( checkRequired("price", price), checkRequired("startDate", startDate), checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, + metricParameterOverrides, additionalProperties.toMutableMap(), ) } @@ -822,6 +875,7 @@ private constructor( price().validate() startDate() usageCustomerIds() + metricParameterOverrides().ifPresent { it.validate() } validated = true } @@ -851,7 +905,116 @@ private constructor( ?: 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + - (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Override values for parameterized billable metric variables. Keys are parameter names, values + * are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -870,6 +1033,7 @@ private constructor( price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && + metricParameterOverrides == other.metricParameterOverrides && additionalProperties == other.additionalProperties } @@ -886,6 +1050,7 @@ private constructor( price, startDate, usageCustomerIds, + metricParameterOverrides, additionalProperties, ) } @@ -893,5 +1058,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, metricParameterOverrides=$metricParameterOverrides, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index bcb06988b..0b54f5ad4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -4477,6 +4477,7 @@ private constructor( private val endDate: JsonField, private val externalPriceId: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, @@ -4502,6 +4503,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -4519,6 +4523,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4572,6 +4577,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4665,6 +4680,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -4735,6 +4761,8 @@ private constructor( private var endDate: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() @@ -4749,6 +4777,7 @@ private constructor( endDate = addPrice.endDate externalPriceId = addPrice.externalPriceId maximumAmount = addPrice.maximumAmount + metricParameterOverrides = addPrice.metricParameterOverrides minimumAmount = addPrice.minimumAmount planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price @@ -4876,6 +4905,32 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -5169,6 +5224,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -5190,6 +5246,7 @@ private constructor( endDate() externalPriceId() maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } minimumAmount() planPhaseOrder() price().ifPresent { it.validate() } @@ -5219,12 +5276,126 @@ private constructor( (if (endDate.asKnown().isPresent) 1 else 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -6594,6 +6765,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -6652,6 +6824,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6675,6 +6850,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -6834,6 +7010,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7003,6 +7187,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7076,6 +7270,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7099,6 +7294,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -7517,6 +7713,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7613,6 +7830,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -7646,6 +7864,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -7683,6 +7902,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -8680,6 +8900,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8703,6 +8924,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8712,7 +8934,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -8735,6 +8957,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8794,6 +9017,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8817,6 +9043,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8976,6 +9203,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9145,6 +9380,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9220,6 +9465,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9244,6 +9490,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -9664,6 +9911,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9760,6 +10028,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9793,6 +10062,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -9832,6 +10102,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -10546,6 +10817,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10569,6 +10841,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10578,7 +10851,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -10602,6 +10875,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10662,6 +10936,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10685,6 +10962,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10846,6 +11124,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -11015,6 +11301,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11092,6 +11388,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11119,6 +11416,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -11546,6 +11844,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11645,6 +11964,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -11678,6 +11998,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -11717,6 +12038,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -12339,6 +12661,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12362,6 +12685,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12371,7 +12695,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -12395,6 +12719,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12455,6 +12780,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12478,6 +12806,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12639,6 +12968,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12808,6 +13145,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12885,6 +13232,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12912,6 +13260,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -13339,6 +13688,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13438,6 +13808,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13471,6 +13842,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13510,6 +13882,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -14139,6 +14512,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -14162,6 +14536,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -14171,7 +14546,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -14194,6 +14569,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -14252,6 +14628,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -14275,6 +14654,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -14433,6 +14813,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -14601,6 +14989,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -14674,6 +15072,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -14696,6 +15095,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -15114,6 +15514,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -15210,6 +15631,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -15243,6 +15665,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -15280,6 +15703,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -15749,6 +16173,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -15772,6 +16197,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -15781,7 +16207,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -15804,6 +16230,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -15862,6 +16289,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -15885,6 +16315,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -16044,6 +16475,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -16212,6 +16651,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -16285,6 +16734,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -16307,6 +16757,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -16725,6 +17176,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -16821,6 +17293,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -16854,6 +17327,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -16891,6 +17365,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -17480,6 +17955,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -17503,6 +17979,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -17512,7 +17989,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -17527,6 +18004,7 @@ private constructor( endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && @@ -17542,6 +18020,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -17554,7 +18033,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } @Deprecated("deprecated") @@ -18741,6 +19220,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val price: JsonField, private val priceId: JsonField, @@ -18767,6 +19247,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -18779,6 +19262,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -18839,6 +19323,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. @@ -18926,6 +19420,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -18985,6 +19490,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -18998,6 +19505,7 @@ private constructor( externalPriceId = replacePrice.externalPriceId fixedPriceQuantity = replacePrice.fixedPriceQuantity maximumAmount = replacePrice.maximumAmount + metricParameterOverrides = replacePrice.metricParameterOverrides minimumAmount = replacePrice.minimumAmount price = replacePrice.price priceId = replacePrice.priceId @@ -19150,6 +19658,32 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. @@ -19404,6 +19938,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -19424,6 +19959,7 @@ private constructor( externalPriceId() fixedPriceQuantity() maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } minimumAmount() price().ifPresent { it.validate() } priceId() @@ -19452,10 +19988,124 @@ private constructor( (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -20825,6 +21475,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -20883,6 +21534,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -20906,6 +21560,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -21065,6 +21720,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -21234,6 +21897,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -21307,6 +21980,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -21330,6 +22004,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -21748,6 +22423,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -21844,6 +22540,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -21877,6 +22574,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -21914,6 +22612,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -22911,6 +23610,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -22934,6 +23634,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -22943,7 +23644,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -22966,6 +23667,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23025,6 +23727,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23048,6 +23753,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23207,6 +23913,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -23376,6 +24090,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -23451,6 +24175,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -23475,6 +24200,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -23895,6 +24621,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -23991,6 +24738,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24024,6 +24772,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -24063,6 +24812,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -24777,6 +25527,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24800,6 +25551,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24809,7 +25561,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -24833,6 +25585,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24893,6 +25646,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24916,6 +25672,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -25077,6 +25834,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -25246,6 +26011,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25323,6 +26098,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25350,6 +26126,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -25777,6 +26554,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25876,6 +26674,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25909,6 +26708,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -25948,6 +26748,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -26570,6 +27371,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26593,6 +27395,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26602,7 +27405,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -26626,6 +27429,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26686,6 +27490,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26709,6 +27516,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26870,6 +27678,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -27039,6 +27855,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -27116,6 +27942,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -27143,6 +27970,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -27570,6 +28398,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27669,6 +28518,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27702,6 +28552,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -27741,6 +28592,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -28370,6 +29222,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -28393,6 +29246,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -28402,7 +29256,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -28425,6 +29279,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -28483,6 +29338,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -28506,6 +29364,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -28664,6 +29523,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -28832,6 +29699,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -28905,6 +29782,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -28927,6 +29805,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -29345,6 +30224,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -29441,6 +30341,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -29474,6 +30375,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -29511,6 +30413,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -29980,6 +30883,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -30003,6 +30907,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -30012,7 +30917,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -30035,6 +30940,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -30093,6 +30999,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -30116,6 +31025,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -30275,6 +31185,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -30443,6 +31361,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -30516,6 +31444,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -30538,6 +31467,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -30956,6 +31886,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -31052,6 +32003,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -31085,6 +32037,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -31122,6 +32075,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -31711,6 +32665,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -31734,6 +32689,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -31743,7 +32699,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -31759,6 +32715,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -31773,6 +32730,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -31783,7 +32741,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 78a8ddd69..4df68c899 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -1027,6 +1027,7 @@ private constructor( private val filter: JsonField, private val fixedFeeQuantityTransitions: JsonField>, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val price: JsonField, private val priceId: JsonField, @@ -1062,6 +1063,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -1080,6 +1084,7 @@ private constructor( filter, fixedFeeQuantityTransitions, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -1167,6 +1172,16 @@ private constructor( */ fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * The minimum amount that will be billed for this price interval for a given billing * period. @@ -1288,6 +1303,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -1361,6 +1387,8 @@ private constructor( JsonField>? = null private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -1379,6 +1407,7 @@ private constructor( fixedFeeQuantityTransitions = add.fixedFeeQuantityTransitions.map { it.toMutableList() } maximumAmount = add.maximumAmount + metricParameterOverrides = add.metricParameterOverrides minimumAmount = add.minimumAmount price = add.price priceId = add.priceId @@ -1672,6 +1701,32 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values (number or string). + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * The minimum amount that will be billed for this price interval for a given billing * period. @@ -1973,6 +2028,7 @@ private constructor( filter, (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -1997,6 +2053,7 @@ private constructor( filter() fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } minimumAmount() price().ifPresent { it.validate() } priceId() @@ -2030,6 +2087,7 @@ private constructor( (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + @@ -3489,6 +3547,119 @@ private constructor( "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -4834,6 +5005,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -4891,6 +5063,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -4911,6 +5086,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -5069,6 +5245,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5229,6 +5413,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5293,6 +5487,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5315,6 +5510,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -5726,6 +5922,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -5801,6 +6018,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -5833,6 +6051,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -5869,6 +6088,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -6865,6 +7085,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6887,6 +7108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6895,7 +7117,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -6919,6 +7141,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -6978,6 +7201,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6998,6 +7224,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -7158,6 +7385,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7318,6 +7553,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7386,6 +7631,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7412,6 +7658,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata additionalProperties = groupedWithMinMaxThresholds.additionalProperties.toMutableMap() @@ -7832,6 +8079,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7910,6 +8178,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -7942,6 +8211,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -7980,6 +8250,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8601,6 +8872,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8623,6 +8895,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8631,7 +8904,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -8655,6 +8928,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8714,6 +8988,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8734,6 +9011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8894,6 +9172,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9054,6 +9340,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9122,6 +9418,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9148,6 +9445,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata additionalProperties = cumulativeGroupedAllocation.additionalProperties.toMutableMap() @@ -9568,6 +9866,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9646,6 +9965,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9678,6 +9998,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -9716,6 +10037,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -10344,6 +10666,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -10366,6 +10689,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -10374,7 +10698,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -10397,6 +10721,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -10454,6 +10779,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10474,6 +10802,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -10631,6 +10960,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10790,6 +11127,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10854,6 +11201,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10875,6 +11223,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -11286,6 +11635,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11361,6 +11731,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -11393,6 +11764,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -11429,6 +11801,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -11897,6 +12270,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -11919,6 +12293,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -11927,7 +12302,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -11950,6 +12325,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -12007,6 +12383,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12027,6 +12406,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -12185,6 +12565,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12344,6 +12732,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12408,6 +12806,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12429,6 +12828,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -12840,6 +13240,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12915,6 +13336,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -12947,6 +13369,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -12983,6 +13406,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -13571,6 +13995,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -13593,6 +14018,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -13601,7 +14027,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } @@ -13620,6 +14046,7 @@ private constructor( filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -13638,6 +14065,7 @@ private constructor( filter, fixedFeeQuantityTransitions, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -13649,7 +14077,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Add{startDate=$startDate, allocationPrice=$allocationPrice, canDeferBilling=$canDeferBilling, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "Add{startDate=$startDate, allocationPrice=$allocationPrice, canDeferBilling=$canDeferBilling, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } class AddAdjustment @@ -14737,6 +15165,7 @@ private constructor( private val endDate: JsonField, private val filter: JsonField, private val fixedFeeQuantityTransitions: JsonField>, + private val metricParameterOverrides: JsonField, private val startDate: JsonField, private val usageCustomerIds: JsonField>, private val additionalProperties: MutableMap, @@ -14761,6 +15190,9 @@ private constructor( @ExcludeMissing fixedFeeQuantityTransitions: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing startDate: JsonField = JsonMissing.of(), @@ -14774,6 +15206,7 @@ private constructor( endDate, filter, fixedFeeQuantityTransitions, + metricParameterOverrides, startDate, usageCustomerIds, mutableMapOf(), @@ -14835,6 +15268,16 @@ private constructor( fun fixedFeeQuantityTransitions(): Optional> = fixedFeeQuantityTransitions.getOptional("fixed_fee_quantity_transitions") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * The updated start date of this price interval. If not specified, the start date will not * be updated. @@ -14912,6 +15355,17 @@ private constructor( fun _fixedFeeQuantityTransitions(): JsonField> = fixedFeeQuantityTransitions + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [startDate]. * @@ -14967,6 +15421,8 @@ private constructor( private var fixedFeeQuantityTransitions: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var startDate: JsonField = JsonMissing.of() private var usageCustomerIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14980,6 +15436,7 @@ private constructor( filter = edit.filter fixedFeeQuantityTransitions = edit.fixedFeeQuantityTransitions.map { it.toMutableList() } + metricParameterOverrides = edit.metricParameterOverrides startDate = edit.startDate usageCustomerIds = edit.usageCustomerIds.map { it.toMutableList() } additionalProperties = edit.additionalProperties.toMutableMap() @@ -15154,6 +15611,32 @@ private constructor( } } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values (number or string). + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * The updated start date of this price interval. If not specified, the start date will * not be updated. @@ -15258,6 +15741,7 @@ private constructor( endDate, filter, (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, startDate, (usageCustomerIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -15277,6 +15761,7 @@ private constructor( endDate().ifPresent { it.validate() } filter() fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } + metricParameterOverrides().ifPresent { it.validate() } startDate().ifPresent { it.validate() } usageCustomerIds() validated = true @@ -15305,6 +15790,7 @@ private constructor( (if (filter.asKnown().isPresent) 1 else 0) + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (startDate.asKnown().getOrNull()?.validity() ?: 0) + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) @@ -15714,6 +16200,119 @@ private constructor( "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** * The updated start date of this price interval. If not specified, the start date will not * be updated. @@ -15914,6 +16513,7 @@ private constructor( endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && + metricParameterOverrides == other.metricParameterOverrides && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties @@ -15927,6 +16527,7 @@ private constructor( endDate, filter, fixedFeeQuantityTransitions, + metricParameterOverrides, startDate, usageCustomerIds, additionalProperties, @@ -15936,7 +16537,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Edit{priceIntervalId=$priceIntervalId, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "Edit{priceIntervalId=$priceIntervalId, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, metricParameterOverrides=$metricParameterOverrides, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } class EditAdjustment diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 937589fde..4f6a250e0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -4081,6 +4081,7 @@ private constructor( private val endDate: JsonField, private val externalPriceId: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, @@ -4106,6 +4107,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -4123,6 +4127,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4176,6 +4181,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4269,6 +4284,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -4339,6 +4365,8 @@ private constructor( private var endDate: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() @@ -4353,6 +4381,7 @@ private constructor( endDate = addPrice.endDate externalPriceId = addPrice.externalPriceId maximumAmount = addPrice.maximumAmount + metricParameterOverrides = addPrice.metricParameterOverrides minimumAmount = addPrice.minimumAmount planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price @@ -4480,6 +4509,32 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4773,6 +4828,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4794,6 +4850,7 @@ private constructor( endDate() externalPriceId() maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } minimumAmount() planPhaseOrder() price().ifPresent { it.validate() } @@ -4823,12 +4880,126 @@ private constructor( (if (endDate.asKnown().isPresent) 1 else 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -6198,6 +6369,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -6256,6 +6428,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6279,6 +6454,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -6438,6 +6614,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -6607,6 +6791,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6680,6 +6874,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6703,6 +6898,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -7121,6 +7317,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7217,6 +7434,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -7250,6 +7468,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -7287,6 +7506,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -8284,6 +8504,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8307,6 +8528,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8316,7 +8538,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -8339,6 +8561,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8398,6 +8621,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8421,6 +8647,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8580,6 +8807,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8749,6 +8984,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8824,6 +9069,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8848,6 +9094,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -9268,6 +9515,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9364,6 +9632,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9397,6 +9666,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -9436,6 +9706,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -10150,6 +10421,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10173,6 +10445,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10182,7 +10455,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -10206,6 +10479,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10266,6 +10540,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10289,6 +10566,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10450,6 +10728,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10619,6 +10905,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10696,6 +10992,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10723,6 +11020,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -11150,6 +11448,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11249,6 +11568,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -11282,6 +11602,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -11321,6 +11642,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -11943,6 +12265,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -11966,6 +12289,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -11975,7 +12299,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -11999,6 +12323,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12059,6 +12384,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12082,6 +12410,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12243,6 +12572,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12412,6 +12749,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12489,6 +12836,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12516,6 +12864,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -12943,6 +13292,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13042,6 +13412,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13075,6 +13446,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13114,6 +13486,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13743,6 +14116,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -13766,6 +14140,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13775,7 +14150,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -13798,6 +14173,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -13856,6 +14232,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -13879,6 +14258,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -14037,6 +14417,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -14205,6 +14593,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -14278,6 +14676,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -14300,6 +14699,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -14718,6 +15118,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -14814,6 +15235,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -14847,6 +15269,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -14884,6 +15307,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -15353,6 +15777,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -15376,6 +15801,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -15385,7 +15811,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -15408,6 +15834,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -15466,6 +15893,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -15489,6 +15919,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -15648,6 +16079,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -15816,6 +16255,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -15889,6 +16338,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -15911,6 +16361,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -16329,6 +16780,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -16425,6 +16897,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -16458,6 +16931,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -16495,6 +16969,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -17084,6 +17559,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -17107,6 +17583,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -17116,7 +17593,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -17131,6 +17608,7 @@ private constructor( endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && @@ -17146,6 +17624,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -17158,7 +17637,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" } /** @@ -18245,6 +18724,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val price: JsonField, private val priceId: JsonField, @@ -18271,6 +18751,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -18283,6 +18766,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -18343,6 +18827,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. @@ -18430,6 +18924,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -18489,6 +18994,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -18502,6 +19009,7 @@ private constructor( externalPriceId = replacePrice.externalPriceId fixedPriceQuantity = replacePrice.fixedPriceQuantity maximumAmount = replacePrice.maximumAmount + metricParameterOverrides = replacePrice.metricParameterOverrides minimumAmount = replacePrice.minimumAmount price = replacePrice.price priceId = replacePrice.priceId @@ -18654,6 +19162,32 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. @@ -18908,6 +19442,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -18928,6 +19463,7 @@ private constructor( externalPriceId() fixedPriceQuantity() maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } minimumAmount() price().ifPresent { it.validate() } priceId() @@ -18956,10 +19492,124 @@ private constructor( (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.additionalProperties.toMutableMap() + } + + 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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -20329,6 +20979,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -20387,6 +21038,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -20410,6 +21064,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -20569,6 +21224,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -20738,6 +21401,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -20811,6 +21484,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -20834,6 +21508,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -21252,6 +21927,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -21348,6 +22044,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -21381,6 +22078,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -21418,6 +22116,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -22415,6 +23114,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -22438,6 +23138,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -22447,7 +23148,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class TieredWithProration @@ -22470,6 +23171,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -22529,6 +23231,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -22552,6 +23257,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -22711,6 +23417,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -22880,6 +23594,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -22955,6 +23679,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -22979,6 +23704,7 @@ private constructor( invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId metadata = tieredWithProration.metadata referenceId = tieredWithProration.referenceId additionalProperties = @@ -23399,6 +24125,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -23495,6 +24242,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -23528,6 +24276,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -23567,6 +24316,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -24281,6 +25031,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24304,6 +25055,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24313,7 +25065,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class GroupedWithMinMaxThresholds @@ -24337,6 +25089,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24397,6 +25150,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24420,6 +25176,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -24581,6 +25338,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -24750,6 +25515,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -24827,6 +25602,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -24854,6 +25630,7 @@ private constructor( invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId metadata = groupedWithMinMaxThresholds.metadata referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = @@ -25281,6 +26058,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25380,6 +26178,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25413,6 +26212,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -25452,6 +26252,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -26074,6 +26875,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26097,6 +26899,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26106,7 +26909,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class CumulativeGroupedAllocation @@ -26130,6 +26933,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26190,6 +26994,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26213,6 +27020,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26374,6 +27182,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -26543,6 +27359,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -26620,6 +27446,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -26647,6 +27474,7 @@ private constructor( invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey invoicingCycleConfiguration = cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId metadata = cumulativeGroupedAllocation.metadata referenceId = cumulativeGroupedAllocation.referenceId additionalProperties = @@ -27074,6 +27902,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27173,6 +28022,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27206,6 +28056,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -27245,6 +28096,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -27874,6 +28726,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -27897,6 +28750,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -27906,7 +28760,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -27929,6 +28783,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -27987,6 +28842,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -28010,6 +28868,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -28168,6 +29027,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -28336,6 +29203,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -28409,6 +29286,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -28431,6 +29309,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -28849,6 +29728,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -28945,6 +29845,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -28978,6 +29879,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -29015,6 +29917,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -29484,6 +30387,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -29507,6 +30411,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -29516,7 +30421,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -29539,6 +30444,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -29597,6 +30503,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -29620,6 +30529,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -29779,6 +30689,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -29947,6 +30865,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -30020,6 +30948,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -30042,6 +30971,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -30460,6 +31390,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -30556,6 +31507,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -30589,6 +31541,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -30626,6 +31579,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -31215,6 +32169,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -31238,6 +32193,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -31247,7 +32203,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -31263,6 +32219,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -31277,6 +32234,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -31287,7 +32245,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt index 3dbc378d4..bfcc9586f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsync.kt @@ -18,6 +18,12 @@ import com.withorb.api.models.AlertUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ interface AlertServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt index 37fde9f01..a71e881cf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt @@ -31,6 +31,12 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ class AlertServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AlertServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt index 967124bb3..2a0cb3a2e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt @@ -14,6 +14,11 @@ import com.withorb.api.services.async.beta.ExternalPlanIdServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface BetaServiceAsync { /** @@ -28,6 +33,11 @@ interface BetaServiceAsync { */ fun withOptions(modifier: Consumer): BetaServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdServiceAsync /** This endpoint allows the creation of a new plan version for an existing plan. */ @@ -115,6 +125,11 @@ interface BetaServiceAsync { */ fun withOptions(modifier: Consumer): BetaServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt index 9af837003..50f6461c4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt @@ -27,6 +27,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BetaServiceAsync { @@ -43,6 +48,11 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): BetaServiceAsync = BetaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync = externalPlanId override fun createPlanVersion( @@ -83,6 +93,11 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse = externalPlanId private val createPlanVersionHandler: Handler = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt index 2fc6a156b..e3a348723 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt @@ -15,6 +15,12 @@ import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface CouponServiceAsync { /** @@ -29,6 +35,12 @@ interface CouponServiceAsync { */ fun withOptions(modifier: Consumer): CouponServiceAsync + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionServiceAsync /** @@ -154,6 +166,12 @@ interface CouponServiceAsync { modifier: Consumer ): CouponServiceAsync.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionServiceAsync.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt index d25042cbd..e16d644bd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt @@ -29,6 +29,12 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class CouponServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CouponServiceAsync { @@ -45,6 +51,12 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): CouponServiceAsync = CouponServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionServiceAsync = subscriptions override fun create( @@ -92,6 +104,12 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt index 05a0b24e9..88e1dcd4a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt @@ -7,11 +7,17 @@ import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponse import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditBlockServiceAsync { /** @@ -108,6 +114,58 @@ interface CreditBlockServiceAsync { fun delete(blockId: String, requestOptions: RequestOptions): CompletableFuture = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + /** + * This endpoint returns the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added or allocated from a + * subscription), this endpoint returns the invoices that were created to charge the customer + * for the credit block. For credit blocks with payment schedules spanning multiple periods + * (e.g., monthly payments over 12 months), multiple invoices will be returned. + * + * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices + * list is returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future + * releases. Please contact support before building production integrations against this + * endpoint.** + */ + fun listInvoices(blockId: String): CompletableFuture = + listInvoices(blockId, CreditBlockListInvoicesParams.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + ): CompletableFuture = + listInvoices(blockId, params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams + ): CompletableFuture = + listInvoices(params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) + /** * A view of [CreditBlockServiceAsync] that provides access to raw HTTP responses for each * method. @@ -203,5 +261,48 @@ interface CreditBlockServiceAsync { requestOptions: RequestOptions, ): CompletableFuture = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /credit_blocks/{block_id}/invoices`, but is + * otherwise the same as [CreditBlockServiceAsync.listInvoices]. + */ + fun listInvoices( + blockId: String + ): CompletableFuture> = + listInvoices(blockId, CreditBlockListInvoicesParams.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + ): CompletableFuture> = + listInvoices(blockId, params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams + ): CompletableFuture> = + listInvoices(params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt index 55b2ff1c8..2d215be55 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt @@ -18,12 +18,18 @@ import com.withorb.api.core.http.json import com.withorb.api.core.http.parseable import com.withorb.api.core.prepareAsync import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockServiceAsync { @@ -50,6 +56,13 @@ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions // delete /credit_blocks/{block_id} withRawResponse().delete(params, requestOptions).thenAccept {} + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /credit_blocks/{block_id}/invoices + withRawResponse().listInvoices(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockServiceAsync.WithRawResponse { @@ -122,5 +135,38 @@ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions } } } + + private val listInvoicesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("credit_blocks", params._pathParam(0), "invoices") + .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 { listInvoicesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt index c5e361dde..b3a988db0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.CreditNoteListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ interface CreditNoteServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt index ab1a9466a..7bacce9cc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt @@ -26,6 +26,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ class CreditNoteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt index c81e266bf..64ac879c2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsync.kt @@ -23,6 +23,24 @@ import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CustomerServiceAsync { /** @@ -37,10 +55,50 @@ interface CustomerServiceAsync { */ fun withOptions(modifier: Consumer): CustomerServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun costs(): CostServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionServiceAsync /** @@ -68,8 +126,9 @@ interface CustomerServiceAsync { /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, * `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, - * `billing_address`, and `additional_emails` of an existing customer. Other fields on a - * customer are currently immutable. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` + * can only be set if it has not already been set on the customer. Other fields on a customer + * are currently immutable. */ fun update(customerId: String): CompletableFuture = update(customerId, CustomerUpdateParams.none()) @@ -428,10 +487,50 @@ interface CustomerServiceAsync { modifier: Consumer ): CustomerServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun costs(): CostServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionServiceAsync.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt index e4c490df1..461b40230 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt @@ -39,6 +39,24 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync { @@ -59,10 +77,50 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C override fun withOptions(modifier: Consumer): CustomerServiceAsync = CustomerServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun costs(): CostServiceAsync = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditServiceAsync = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionServiceAsync = balanceTransactions override fun create( @@ -156,10 +214,50 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun costs(): CostServiceAsync.WithRawResponse = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditServiceAsync.WithRawResponse = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionServiceAsync.WithRawResponse = balanceTransactions diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt index cbc65eb3e..0a65ba125 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsync.kt @@ -18,6 +18,11 @@ import com.withorb.api.services.async.events.VolumeServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface EventServiceAsync { /** @@ -32,8 +37,18 @@ interface EventServiceAsync { */ fun withOptions(modifier: Consumer): EventServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun backfills(): BackfillServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun volume(): VolumeServiceAsync /** @@ -405,8 +420,18 @@ interface EventServiceAsync { modifier: Consumer ): EventServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun backfills(): BackfillServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun volume(): VolumeServiceAsync.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt index 782512a84..503600c4e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt @@ -32,6 +32,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class EventServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EventServiceAsync { @@ -48,8 +53,18 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): EventServiceAsync = EventServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun backfills(): BackfillServiceAsync = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun volume(): VolumeServiceAsync = volume override fun update( @@ -101,8 +116,18 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun backfills(): BackfillServiceAsync.WithRawResponse = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun volume(): VolumeServiceAsync.WithRawResponse = volume private val updateHandler: Handler = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt index 6837fd01e..6973ff5f0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt @@ -10,6 +10,13 @@ import com.withorb.api.models.InvoiceLineItemCreateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceLineItemServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt index 58ac0b84d..475c73977 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt @@ -20,6 +20,13 @@ import com.withorb.api.models.InvoiceLineItemCreateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceLineItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceLineItemServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt index 6cacdd7e3..ccf65f977 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsync.kt @@ -13,6 +13,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPageAsync import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceListSummaryPageAsync @@ -24,6 +26,13 @@ import com.withorb.api.models.InvoiceVoidInvoiceParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceServiceAsync { /** @@ -49,13 +58,13 @@ interface InvoiceServiceAsync { ): CompletableFuture /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and - * `invoice_date` properties on an invoice. If you pass null for the metadata value, it will - * clear any existing metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` properties on an invoice. If you pass null for the metadata value, it + * will clear any existing metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can - * only be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, + * `invoice_date`, and `auto_collection` can only be modified if the invoice is in a `draft` + * state. `invoice_date` can only be modified for non-subscription invoices. */ fun update(invoiceId: String): CompletableFuture = update(invoiceId, InvoiceUpdateParams.none()) @@ -235,6 +244,52 @@ interface InvoiceServiceAsync { fun issue(invoiceId: String, requestOptions: RequestOptions): CompletableFuture = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * This endpoint allows an eligible invoice to be issued manually. This is only possible with + * invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` + * is a time in the past. Issuing an invoice could possibly trigger side effects, some of which + * could be customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice + * to external providers, etc). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice + * summary without any line item details. + */ + fun issueSummary(invoiceId: String): CompletableFuture = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + ): CompletableFuture = + issueSummary(invoiceId, params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams + ): CompletableFuture = issueSummary(params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * This is a lighter-weight endpoint that returns a list of all * [`Invoice`](/core-concepts#invoice) summaries for an account in a list format. @@ -587,6 +642,49 @@ interface InvoiceServiceAsync { ): CompletableFuture> = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /invoices/summary/{invoice_id}/issue`, but is + * otherwise the same as [InvoiceServiceAsync.issueSummary]. + */ + fun issueSummary( + invoiceId: String + ): CompletableFuture> = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + ): CompletableFuture> = + issueSummary(invoiceId, params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams + ): CompletableFuture> = + issueSummary(params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices/summary`, but is otherwise the same as * [InvoiceServiceAsync.listSummary]. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt index 7ccb58e57..52b383472 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt @@ -24,6 +24,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPageAsync import com.withorb.api.models.InvoiceListPageResponse import com.withorb.api.models.InvoiceListParams @@ -38,6 +40,13 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceServiceAsync { @@ -99,6 +108,13 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl // post /invoices/{invoice_id}/issue withRawResponse().issue(params, requestOptions).thenApply { it.parse() } + override fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /invoices/summary/{invoice_id}/issue + withRawResponse().issueSummary(params, requestOptions).thenApply { it.parse() } + override fun listSummary( params: InvoiceListSummaryParams, requestOptions: RequestOptions, @@ -368,6 +384,40 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl } } + private val issueSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("invoices", "summary", params._pathParam(0), "issue") + .body(json(clientOptions.jsonMapper, params._body())) + .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 { issueSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val listSummaryHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt index 6ba89b364..2620a5cda 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt @@ -15,6 +15,11 @@ import com.withorb.api.models.ItemUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for invoices + * and tax calculation purposes. + */ interface ItemServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt index d17818542..78159acd2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt @@ -28,6 +28,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for invoices + * and tax calculation purposes. + */ class ItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ItemServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt new file mode 100644 index 000000000..57f0bf588 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt @@ -0,0 +1,343 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPageAsync +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsync +import com.withorb.api.services.async.licenses.UsageServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface LicenseServiceAsync { + + /** + * 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): LicenseServiceAsync + + fun externalLicenses(): ExternalLicenseServiceAsync + + fun usage(): UsageServiceAsync + + /** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified + * date in the customer's timezone. Otherwise, the activation time will default to the **start** + * of the current day in the customer's timezone. + */ + fun create(params: LicenseCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This endpoint is used to fetch a license given an identifier. */ + fun retrieve(licenseId: String): CompletableFuture = + retrieve(licenseId, LicenseRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + ): CompletableFuture = + retrieve(licenseId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: LicenseRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** This endpoint returns a list of all licenses for a subscription. */ + fun list(params: LicenseListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** + * of the current day in the customer's timezone. + */ + fun deactivate(licenseId: String): CompletableFuture = + deactivate(licenseId, LicenseDeactivateParams.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + ): CompletableFuture = + deactivate(licenseId, params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see deactivate */ + fun deactivate(params: LicenseDeactivateParams): CompletableFuture = + deactivate(params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** This endpoint is used to fetch a license given an external license identifier. */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + ): CompletableFuture = + retrieveByExternalId(externalLicenseId, params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams + ): CompletableFuture = + retrieveByExternalId(params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [LicenseServiceAsync] 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 + ): LicenseServiceAsync.WithRawResponse + + fun externalLicenses(): ExternalLicenseServiceAsync.WithRawResponse + + fun usage(): UsageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /licenses`, but is otherwise the same as + * [LicenseServiceAsync.create]. + */ + fun create( + params: LicenseCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}`, but is otherwise the same + * as [LicenseServiceAsync.retrieve]. + */ + fun retrieve( + licenseId: String + ): CompletableFuture> = + retrieve(licenseId, LicenseRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + ): CompletableFuture> = + retrieve(licenseId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /licenses`, but is otherwise the same as + * [LicenseServiceAsync.list]. + */ + fun list( + params: LicenseListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /licenses/{license_id}/deactivate`, but is + * otherwise the same as [LicenseServiceAsync.deactivate]. + */ + fun deactivate( + licenseId: String + ): CompletableFuture> = + deactivate(licenseId, LicenseDeactivateParams.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + ): CompletableFuture> = + deactivate(licenseId, params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams + ): CompletableFuture> = + deactivate(params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /licenses/external_license_id/{external_license_id}`, but is otherwise the same as + * [LicenseServiceAsync.retrieveByExternalId]. + */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + ): CompletableFuture> = + retrieveByExternalId(externalLicenseId, params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams + ): CompletableFuture> = + retrieveByExternalId(params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt new file mode 100644 index 000000000..50d467a57 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt @@ -0,0 +1,290 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPageAsync +import com.withorb.api.models.LicenseListPageResponse +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsync +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsyncImpl +import com.withorb.api.services.async.licenses.UsageServiceAsync +import com.withorb.api.services.async.licenses.UsageServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class LicenseServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseServiceAsync { + + private val withRawResponse: LicenseServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val externalLicenses: ExternalLicenseServiceAsync by lazy { + ExternalLicenseServiceAsyncImpl(clientOptions) + } + + private val usage: UsageServiceAsync by lazy { UsageServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): LicenseServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LicenseServiceAsync = + LicenseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun externalLicenses(): ExternalLicenseServiceAsync = externalLicenses + + override fun usage(): UsageServiceAsync = usage + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /licenses + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/{license_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /licenses/{license_id}/deactivate + withRawResponse().deactivate(params, requestOptions).thenApply { it.parse() } + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/external_license_id/{external_license_id} + withRawResponse().retrieveByExternalId(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val externalLicenses: ExternalLicenseServiceAsync.WithRawResponse by lazy { + ExternalLicenseServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val usage: UsageServiceAsync.WithRawResponse by lazy { + UsageServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): LicenseServiceAsync.WithRawResponse = + LicenseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun externalLicenses(): ExternalLicenseServiceAsync.WithRawResponse = + externalLicenses + + override fun usage(): UsageServiceAsync.WithRawResponse = usage + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .body(json(clientOptions.jsonMapper, params._body())) + .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 { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0)) + .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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .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 { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseListPageAsync.builder() + .service(LicenseServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val deactivateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "deactivate") + .body(json(clientOptions.jsonMapper, params._body())) + .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 { deactivateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_license_id", params._pathParam(0)) + .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 { retrieveByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt new file mode 100644 index 000000000..e0df3d1cc --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPageAsync +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +interface LicenseTypeServiceAsync { + + /** + * 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): LicenseTypeServiceAsync + + /** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun create(params: LicenseTypeCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This endpoint returns a license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ + fun retrieve(licenseTypeId: String): CompletableFuture = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + ): CompletableFuture = + retrieve(licenseTypeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * This endpoint returns a list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun list(): CompletableFuture = list(LicenseTypeListParams.none()) + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(LicenseTypeListParams.none(), requestOptions) + + /** + * A view of [LicenseTypeServiceAsync] 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 + ): LicenseTypeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /license_types`, but is otherwise the same as + * [LicenseTypeServiceAsync.create]. + */ + fun create( + params: LicenseTypeCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /license_types/{license_type_id}`, but is otherwise + * the same as [LicenseTypeServiceAsync.retrieve]. + */ + fun retrieve( + licenseTypeId: String + ): CompletableFuture> = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + ): CompletableFuture> = + retrieve(licenseTypeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /license_types`, but is otherwise the same as + * [LicenseTypeServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(LicenseTypeListParams.none()) + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(LicenseTypeListParams.none(), requestOptions) + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt new file mode 100644 index 000000000..4c82d5aae --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPageAsync +import com.withorb.api.models.LicenseTypeListPageResponse +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeServiceAsync { + + private val withRawResponse: LicenseTypeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LicenseTypeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LicenseTypeServiceAsync = + LicenseTypeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /license_types + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /license_types/{license_type_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /license_types + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): LicenseTypeServiceAsync.WithRawResponse = + LicenseTypeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .body(json(clientOptions.jsonMapper, params._body())) + .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 { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseTypeId", params.licenseTypeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types", params._pathParam(0)) + .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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .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 { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseTypeListPageAsync.builder() + .service(LicenseTypeServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt index 7e15b6dc4..4040833eb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt @@ -14,6 +14,10 @@ import com.withorb.api.models.MetricUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ interface MetricServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt index 756da69a9..773ae6bc0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt @@ -27,6 +27,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ class MetricServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MetricServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt index 9accb5d87..63d9dff9f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsync.kt @@ -16,6 +16,11 @@ import com.withorb.api.services.async.plans.MigrationServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface PlanServiceAsync { /** @@ -30,8 +35,18 @@ interface PlanServiceAsync { */ fun withOptions(modifier: Consumer): PlanServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun migrations(): MigrationServiceAsync /** This endpoint allows creation of plans including their prices. */ @@ -156,8 +171,18 @@ interface PlanServiceAsync { */ fun withOptions(modifier: Consumer): PlanServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun migrations(): MigrationServiceAsync.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt index ae6338a27..8bd4bdd34 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt @@ -31,6 +31,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class PlanServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PlanServiceAsync { @@ -51,8 +56,18 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): PlanServiceAsync = PlanServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync = externalPlanId + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun migrations(): MigrationServiceAsync = migrations override fun create( @@ -104,8 +119,18 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse = externalPlanId + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun migrations(): MigrationServiceAsync.WithRawResponse = migrations private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt index a1b0957b6..089505039 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt @@ -5,6 +5,32 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.NewFloatingBulkPrice +import com.withorb.api.models.NewFloatingBulkWithProrationPrice +import com.withorb.api.models.NewFloatingCumulativeGroupedBulkPrice +import com.withorb.api.models.NewFloatingGroupedAllocationPrice +import com.withorb.api.models.NewFloatingGroupedTieredPackagePrice +import com.withorb.api.models.NewFloatingGroupedTieredPrice +import com.withorb.api.models.NewFloatingGroupedWithMeteredMinimumPrice +import com.withorb.api.models.NewFloatingGroupedWithProratedMinimumPrice +import com.withorb.api.models.NewFloatingMatrixPrice +import com.withorb.api.models.NewFloatingMatrixWithAllocationPrice +import com.withorb.api.models.NewFloatingMatrixWithDisplayNamePrice +import com.withorb.api.models.NewFloatingMaxGroupTieredPackagePrice +import com.withorb.api.models.NewFloatingMinimumCompositePrice +import com.withorb.api.models.NewFloatingPackagePrice +import com.withorb.api.models.NewFloatingPackageWithAllocationPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithTieredPricingPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithUnitPricingPrice +import com.withorb.api.models.NewFloatingThresholdTotalAmountPrice +import com.withorb.api.models.NewFloatingTieredPackagePrice +import com.withorb.api.models.NewFloatingTieredPackageWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredPrice +import com.withorb.api.models.NewFloatingTieredWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredWithProrationPrice +import com.withorb.api.models.NewFloatingUnitPrice +import com.withorb.api.models.NewFloatingUnitWithPercentPrice +import com.withorb.api.models.NewFloatingUnitWithProrationPrice import com.withorb.api.models.Price import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams @@ -21,6 +47,18 @@ import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface PriceServiceAsync { /** @@ -35,6 +73,18 @@ interface PriceServiceAsync { */ fun withOptions(modifier: Consumer): PriceServiceAsync + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdServiceAsync /** @@ -58,6 +108,401 @@ interface PriceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see create */ + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + fun create(body: PriceCreateParams.Body): CompletableFuture = + create(body, RequestOptions.none()) + + /** @see create */ + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + fun create(unit: NewFloatingUnitPrice): CompletableFuture = + create(unit, RequestOptions.none()) + + /** @see create */ + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + fun create(tiered: NewFloatingTieredPrice): CompletableFuture = + create(tiered, RequestOptions.none()) + + /** @see create */ + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + fun create(bulk: NewFloatingBulkPrice): CompletableFuture = + create(bulk, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + fun create(bulkWithFilters: PriceCreateParams.Body.BulkWithFilters): CompletableFuture = + create(bulkWithFilters, RequestOptions.none()) + + /** @see create */ + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + fun create(package_: NewFloatingPackagePrice): CompletableFuture = + create(package_, RequestOptions.none()) + + /** @see create */ + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + fun create(matrix: NewFloatingMatrixPrice): CompletableFuture = + create(matrix, RequestOptions.none()) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), requestOptions) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice + ): CompletableFuture = create(thresholdTotalAmount, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + fun create(tieredPackage: NewFloatingTieredPackagePrice): CompletableFuture = + create(tieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + fun create(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): CompletableFuture = + create(tieredWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + fun create(groupedTiered: NewFloatingGroupedTieredPrice): CompletableFuture = + create(groupedTiered, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice + ): CompletableFuture = create(tieredPackageWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ): CompletableFuture = create(packageWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + fun create(unitWithPercent: NewFloatingUnitWithPercentPrice): CompletableFuture = + create(unitWithPercent, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), requestOptions) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): CompletableFuture = create(matrixWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), requestOptions) + + /** @see create */ + fun create(tieredWithProration: NewFloatingTieredWithProrationPrice): CompletableFuture = + create(tieredWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + fun create(unitWithProration: NewFloatingUnitWithProrationPrice): CompletableFuture = + create(unitWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + fun create(groupedAllocation: NewFloatingGroupedAllocationPrice): CompletableFuture = + create(groupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + fun create(bulkWithProration: NewFloatingBulkWithProrationPrice): CompletableFuture = + create(bulkWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice + ): CompletableFuture = create(groupedWithProratedMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice + ): CompletableFuture = create(groupedWithMeteredMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds + ): CompletableFuture = create(groupedWithMinMaxThresholds, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + ): CompletableFuture = create(matrixWithDisplayName, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), requestOptions) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice + ): CompletableFuture = create(groupedTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): CompletableFuture = create(maxGroupTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice + ): CompletableFuture = create(scalableMatrixWithUnitPricing, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice + ): CompletableFuture = create(scalableMatrixWithTieredPricing, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice + ): CompletableFuture = create(cumulativeGroupedBulk, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation + ): CompletableFuture = create(cumulativeGroupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + fun create(minimumComposite: NewFloatingMinimumCompositePrice): CompletableFuture = + create(minimumComposite, RequestOptions.none()) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + fun create(percent: PriceCreateParams.Body.Percent): CompletableFuture = + create(percent, RequestOptions.none()) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + + /** @see create */ + fun create(eventOutput: PriceCreateParams.Body.EventOutput): CompletableFuture = + create(eventOutput, RequestOptions.none()) + /** * This endpoint allows you to update the `metadata` property on a price. If you pass null for * the metadata value, it will clear any existing metadata for that price. @@ -266,6 +711,18 @@ interface PriceServiceAsync { modifier: Consumer ): PriceServiceAsync.WithRawResponse + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse /** @@ -281,6 +738,455 @@ interface PriceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see create */ + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + fun create(body: PriceCreateParams.Body): CompletableFuture> = + create(body, RequestOptions.none()) + + /** @see create */ + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + fun create(unit: NewFloatingUnitPrice): CompletableFuture> = + create(unit, RequestOptions.none()) + + /** @see create */ + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + fun create(tiered: NewFloatingTieredPrice): CompletableFuture> = + create(tiered, RequestOptions.none()) + + /** @see create */ + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + fun create(bulk: NewFloatingBulkPrice): CompletableFuture> = + create(bulk, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters + ): CompletableFuture> = + create(bulkWithFilters, RequestOptions.none()) + + /** @see create */ + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + fun create(package_: NewFloatingPackagePrice): CompletableFuture> = + create(package_, RequestOptions.none()) + + /** @see create */ + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + fun create(matrix: NewFloatingMatrixPrice): CompletableFuture> = + create(matrix, RequestOptions.none()) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), + requestOptions, + ) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice + ): CompletableFuture> = + create(thresholdTotalAmount, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice + ): CompletableFuture> = create(tieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice + ): CompletableFuture> = + create(tieredWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice + ): CompletableFuture> = create(groupedTiered, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice + ): CompletableFuture> = + create(tieredPackageWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ): CompletableFuture> = + create(packageWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice + ): CompletableFuture> = + create(unitWithPercent, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): CompletableFuture> = + create(matrixWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), + requestOptions, + ) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice + ): CompletableFuture> = + create(tieredWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice + ): CompletableFuture> = + create(unitWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice + ): CompletableFuture> = + create(groupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice + ): CompletableFuture> = + create(bulkWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice + ): CompletableFuture> = + create(groupedWithProratedMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice + ): CompletableFuture> = + create(groupedWithMeteredMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds + ): CompletableFuture> = + create(groupedWithMinMaxThresholds, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + ): CompletableFuture> = + create(matrixWithDisplayName, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice + ): CompletableFuture> = + create(groupedTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): CompletableFuture> = + create(maxGroupTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice + ): CompletableFuture> = + create(scalableMatrixWithUnitPricing, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice + ): CompletableFuture> = + create(scalableMatrixWithTieredPricing, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice + ): CompletableFuture> = + create(cumulativeGroupedBulk, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation + ): CompletableFuture> = + create(cumulativeGroupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice + ): CompletableFuture> = + create(minimumComposite, RequestOptions.none()) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent + ): CompletableFuture> = create(percent, RequestOptions.none()) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput + ): CompletableFuture> = create(eventOutput, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the same as * [PriceServiceAsync.update]. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt index e7573d2e5..bb0b1c978 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt @@ -35,6 +35,18 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class PriceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PriceServiceAsync { @@ -51,6 +63,18 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): PriceServiceAsync = PriceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdServiceAsync = externalPriceId override fun create( @@ -119,6 +143,18 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse = externalPriceId diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt index d61e2b77c..03ae4cc12 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt @@ -13,6 +13,11 @@ import com.withorb.api.models.PlanVersion import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface ExternalPlanIdServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt index 3d41085ce..ccc0cad47 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt @@ -25,6 +25,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class ExternalPlanIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt index 30c2d43df..676d2e207 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt @@ -10,6 +10,12 @@ import com.withorb.api.models.CouponSubscriptionListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface SubscriptionServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt index 1695a6e13..7963b5f8b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt @@ -22,6 +22,12 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt index 8fa16a1ff..c50d2d28e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt @@ -12,6 +12,24 @@ import com.withorb.api.models.CustomerBalanceTransactionListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface BalanceTransactionServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt index a9c5ec052..c49f3a2bf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt @@ -25,6 +25,24 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class BalanceTransactionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt index 45db99c9b..8e643fa93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsync.kt @@ -12,6 +12,24 @@ import com.withorb.api.models.CustomerCostListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CostServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt index 3c1970d8c..f5288571b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt @@ -23,6 +23,24 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CostServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CostServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt index 59bc036ab..5491d9b73 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt @@ -14,6 +14,10 @@ import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditServiceAsync { /** @@ -28,8 +32,16 @@ interface CreditServiceAsync { */ fun withOptions(modifier: Consumer): CreditServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpServiceAsync /** @@ -40,6 +52,11 @@ interface CreditServiceAsync { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun list(customerId: String): CompletableFuture = list(customerId, CustomerCreditListParams.none()) @@ -84,6 +101,11 @@ interface CreditServiceAsync { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun listByExternalId( externalCustomerId: String @@ -145,8 +167,16 @@ interface CreditServiceAsync { modifier: Consumer ): CreditServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpServiceAsync.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt index 41f0ffa95..37b2d2a98 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt @@ -29,6 +29,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditServiceAsync { @@ -45,8 +49,16 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): CreditServiceAsync = CreditServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerServiceAsync = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpServiceAsync = topUps override fun list( @@ -84,8 +96,16 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerServiceAsync.WithRawResponse = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpServiceAsync.WithRawResponse = topUps private val listHandler: Handler = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt index bee830085..d3f4768a8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsync.kt @@ -16,6 +16,10 @@ import com.withorb.api.models.CustomerCreditLedgerListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface LedgerServiceAsync { /** @@ -54,10 +58,8 @@ interface LedgerServiceAsync { * * As usage for a customer is reported into Orb, credits may be deducted according to the * customer's plan configuration. An automated deduction of this type will result in a ledger - * entry, also with a starting and ending balance. In order to provide better tracing - * capabilities for automatic deductions, Orb always associates each automatic deduction with - * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place - * and to ensure that credits are never deducted without an associated usage event. + * entry, also with a starting and ending balance. Each day's usage for a particular price, + * invoice, and block will be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring * credit block* first in order to ensure that all credits are utilized appropriately. As an @@ -181,7 +183,13 @@ interface LedgerServiceAsync { * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying - * the cost basis with the number of credit units added. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. @@ -306,7 +314,13 @@ interface LedgerServiceAsync { * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying - * the cost basis with the number of credit units added. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. @@ -415,10 +429,8 @@ interface LedgerServiceAsync { * * As usage for a customer is reported into Orb, credits may be deducted according to the * customer's plan configuration. An automated deduction of this type will result in a ledger - * entry, also with a starting and ending balance. In order to provide better tracing - * capabilities for automatic deductions, Orb always associates each automatic deduction with - * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place - * and to ensure that credits are never deducted without an associated usage event. + * entry, also with a starting and ending balance. Each day's usage for a particular price, + * invoice, and block will be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring * credit block* first in order to ensure that all credits are utilized appropriately. As an diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt index 671f24628..b34ef4c69 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt @@ -30,6 +30,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LedgerServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt index 6134a4dcf..ed0721697 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt @@ -19,6 +19,10 @@ import com.withorb.api.models.CustomerCreditTopUpListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface TopUpServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt index 5066212e6..f10916171 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt @@ -33,6 +33,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TopUpServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt index 878325bf2..6eb3efc5a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsync.kt @@ -18,6 +18,11 @@ import com.withorb.api.models.EventBackfillRevertResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface BackfillServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt index 6ca450b93..1949b6257 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt @@ -31,6 +31,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class BackfillServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BackfillServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt index fcea10725..2910fde9c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt @@ -10,6 +10,11 @@ import com.withorb.api.models.EventVolumes import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface VolumeServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt index bdb94fcc3..2d5b37982 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt @@ -19,6 +19,11 @@ import com.withorb.api.models.EventVolumes import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class VolumeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : VolumeServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt new file mode 100644 index 000000000..289c08001 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ExternalLicenseServiceAsync { + + /** + * 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): ExternalLicenseServiceAsync + + /** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + ): CompletableFuture = + getUsage(externalLicenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + getUsage(params.toBuilder().externalLicenseId(externalLicenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams + ): CompletableFuture = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [ExternalLicenseServiceAsync] 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 + ): ExternalLicenseServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /licenses/external_licenses/{external_license_id}/usage`, but is otherwise the same as + * [ExternalLicenseServiceAsync.getUsage]. + */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + ): CompletableFuture> = + getUsage(externalLicenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + getUsage( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams + ): CompletableFuture> = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt new file mode 100644 index 000000000..e90011845 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExternalLicenseServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ExternalLicenseServiceAsync { + + private val withRawResponse: ExternalLicenseServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExternalLicenseServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): ExternalLicenseServiceAsync = + ExternalLicenseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/external_licenses/{external_license_id}/usage + withRawResponse().getUsage(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ExternalLicenseServiceAsync.WithRawResponse = + ExternalLicenseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_licenses", params._pathParam(0), "usage") + .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 { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt new file mode 100644 index 000000000..d846cfdd6 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface UsageServiceAsync { + + /** + * 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): UsageServiceAsync + + /** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams + ): CompletableFuture = + getAllUsage(params, RequestOptions.none()) + + /** @see getAllUsage */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage(licenseId: String): CompletableFuture = + getUsage(licenseId, LicenseUsageGetUsageParams.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + ): CompletableFuture = + getUsage(licenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams + ): CompletableFuture = getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + + /** A view of [UsageServiceAsync] 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 + ): UsageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /licenses/usage`, but is otherwise the same as + * [UsageServiceAsync.getAllUsage]. + */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams + ): CompletableFuture> = + getAllUsage(params, RequestOptions.none()) + + /** @see getAllUsage */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}/usage`, but is otherwise the + * same as [UsageServiceAsync.getUsage]. + */ + fun getUsage( + licenseId: String + ): CompletableFuture> = + getUsage(licenseId, LicenseUsageGetUsageParams.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + ): CompletableFuture> = + getUsage(licenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams + ): CompletableFuture> = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt new file mode 100644 index 000000000..8da2e6b38 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class UsageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync { + + private val withRawResponse: UsageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UsageServiceAsync = + UsageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/usage + withRawResponse().getAllUsage(params, requestOptions).thenApply { it.parse() } + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/{license_id}/usage + withRawResponse().getUsage(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UsageServiceAsync.WithRawResponse = + UsageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getAllUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "usage") + .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 { getAllUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "usage") + .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 { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt index 848015d42..90f594b87 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsync.kt @@ -11,6 +11,11 @@ import com.withorb.api.models.PlanExternalPlanIdUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface ExternalPlanIdServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt index f793de045..207b02443 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt @@ -23,6 +23,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class ExternalPlanIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt index 1a9b55908..d0625a60c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt @@ -14,6 +14,11 @@ import com.withorb.api.models.PlanMigrationRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface MigrationServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt index 0b504a915..60f5ddb1f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt @@ -27,6 +27,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class MigrationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MigrationServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt index 34498064e..d9b340534 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt @@ -11,6 +11,18 @@ import com.withorb.api.models.PriceExternalPriceIdUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface ExternalPriceIdServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt index 00580b869..f72116bf6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt @@ -23,6 +23,18 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class ExternalPriceIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt index 5dc8a9e3e..e88e7fa49 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertService.kt @@ -18,6 +18,12 @@ import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams import java.util.function.Consumer +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ interface AlertService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt index daa8d5ff5..48bc0b9d4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt @@ -30,6 +30,12 @@ import com.withorb.api.models.AlertUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ class AlertServiceImpl internal constructor(private val clientOptions: ClientOptions) : AlertService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt index 36350b10c..80a19d174 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt @@ -14,6 +14,11 @@ import com.withorb.api.models.PlanVersion import com.withorb.api.services.blocking.beta.ExternalPlanIdService import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface BetaService { /** @@ -28,6 +33,11 @@ interface BetaService { */ fun withOptions(modifier: Consumer): BetaService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdService /** This endpoint allows the creation of a new plan version for an existing plan. */ @@ -106,6 +116,11 @@ interface BetaService { */ fun withOptions(modifier: Consumer): BetaService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdService.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt index c9916655e..756568347 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt @@ -26,6 +26,11 @@ import com.withorb.api.services.blocking.beta.ExternalPlanIdServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { private val withRawResponse: BetaService.WithRawResponse by lazy { @@ -41,6 +46,11 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): BetaService = BetaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdService = externalPlanId override fun createPlanVersion( @@ -81,6 +91,11 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdService.WithRawResponse = externalPlanId private val createPlanVersionHandler: Handler = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt index c634fc7fd..329f3a6d1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt @@ -15,6 +15,12 @@ import com.withorb.api.models.CouponListParams import com.withorb.api.services.blocking.coupons.SubscriptionService import java.util.function.Consumer +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface CouponService { /** @@ -29,6 +35,12 @@ interface CouponService { */ fun withOptions(modifier: Consumer): CouponService + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionService /** @@ -140,6 +152,12 @@ interface CouponService { */ fun withOptions(modifier: Consumer): CouponService.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionService.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt index 479d31180..9f5c8eca7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt @@ -28,6 +28,12 @@ import com.withorb.api.services.blocking.coupons.SubscriptionServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class CouponServiceImpl internal constructor(private val clientOptions: ClientOptions) : CouponService { @@ -44,6 +50,12 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): CouponService = CouponServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionService = subscriptions override fun create(params: CouponCreateParams, requestOptions: RequestOptions): Coupon = @@ -79,6 +91,12 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt index 2200263f2..9761a15a7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt @@ -8,10 +8,16 @@ import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponse import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditBlockService { /** @@ -98,6 +104,55 @@ interface CreditBlockService { fun delete(blockId: String, requestOptions: RequestOptions) = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + /** + * This endpoint returns the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added or allocated from a + * subscription), this endpoint returns the invoices that were created to charge the customer + * for the credit block. For credit blocks with payment schedules spanning multiple periods + * (e.g., monthly payments over 12 months), multiple invoices will be returned. + * + * If the credit block was not purchased (e.g., manual increment, allocation), an empty invoices + * list is returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future + * releases. Please contact support before building production integrations against this + * endpoint.** + */ + fun listInvoices(blockId: String): CreditBlockListInvoicesResponse = + listInvoices(blockId, CreditBlockListInvoicesParams.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditBlockListInvoicesResponse = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + ): CreditBlockListInvoicesResponse = listInvoices(blockId, params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditBlockListInvoicesResponse + + /** @see listInvoices */ + fun listInvoices(params: CreditBlockListInvoicesParams): CreditBlockListInvoicesResponse = + listInvoices(params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): CreditBlockListInvoicesResponse = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) + /** * A view of [CreditBlockService] that provides access to raw HTTP responses for each method. */ @@ -196,5 +251,52 @@ interface CreditBlockService { @MustBeClosed fun delete(blockId: String, requestOptions: RequestOptions): HttpResponse = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /credit_blocks/{block_id}/invoices`, but is + * otherwise the same as [CreditBlockService.listInvoices]. + */ + @MustBeClosed + fun listInvoices(blockId: String): HttpResponseFor = + listInvoices(blockId, CreditBlockListInvoicesParams.none()) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + ): HttpResponseFor = + listInvoices(blockId, params, RequestOptions.none()) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + params: CreditBlockListInvoicesParams + ): HttpResponseFor = + listInvoices(params, RequestOptions.none()) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt index d5cac1cc2..f65dbb26f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt @@ -18,11 +18,17 @@ import com.withorb.api.core.http.json import com.withorb.api.core.http.parseable import com.withorb.api.core.prepare import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditBlockServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockService { @@ -47,6 +53,13 @@ class CreditBlockServiceImpl internal constructor(private val clientOptions: Cli withRawResponse().delete(params, requestOptions) } + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): CreditBlockListInvoicesResponse = + // get /credit_blocks/{block_id}/invoices + withRawResponse().listInvoices(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockService.WithRawResponse { @@ -113,5 +126,35 @@ class CreditBlockServiceImpl internal constructor(private val clientOptions: Cli response.use { deleteHandler.handle(it) } } } + + private val listInvoicesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("credit_blocks", params._pathParam(0), "invoices") + .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 { listInvoicesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt index f63a19914..02bf7bc9c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt @@ -13,6 +13,10 @@ import com.withorb.api.models.CreditNoteListPage import com.withorb.api.models.CreditNoteListParams import java.util.function.Consumer +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ interface CreditNoteService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt index 14d2f531b..ee8d3fe41 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt @@ -25,6 +25,10 @@ import com.withorb.api.models.CreditNoteListParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ class CreditNoteServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt index 957d0fb9c..05c352985 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerService.kt @@ -23,6 +23,24 @@ import com.withorb.api.services.blocking.customers.CostService import com.withorb.api.services.blocking.customers.CreditService import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CustomerService { /** @@ -37,10 +55,50 @@ interface CustomerService { */ fun withOptions(modifier: Consumer): CustomerService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun costs(): CostService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionService /** @@ -67,8 +125,9 @@ interface CustomerService { /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, * `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, - * `billing_address`, and `additional_emails` of an existing customer. Other fields on a - * customer are currently immutable. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` + * can only be set if it has not already been set on the customer. Other fields on a customer + * are currently immutable. */ fun update(customerId: String): Customer = update(customerId, CustomerUpdateParams.none()) @@ -392,10 +451,50 @@ interface CustomerService { */ fun withOptions(modifier: Consumer): CustomerService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun costs(): CostService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionService.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt index 14a609ddc..1acc9ecb5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt @@ -38,6 +38,24 @@ import com.withorb.api.services.blocking.customers.CreditServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CustomerServiceImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService { @@ -58,10 +76,50 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client override fun withOptions(modifier: Consumer): CustomerService = CustomerServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun costs(): CostService = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditService = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionService = balanceTransactions override fun create(params: CustomerCreateParams, requestOptions: RequestOptions): Customer = @@ -144,10 +202,50 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun costs(): CostService.WithRawResponse = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditService.WithRawResponse = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionService.WithRawResponse = balanceTransactions diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt index fab9f037b..0380e57e2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventService.kt @@ -18,6 +18,11 @@ import com.withorb.api.services.blocking.events.BackfillService import com.withorb.api.services.blocking.events.VolumeService import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface EventService { /** @@ -32,8 +37,18 @@ interface EventService { */ fun withOptions(modifier: Consumer): EventService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun backfills(): BackfillService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun volume(): VolumeService /** @@ -399,8 +414,18 @@ interface EventService { */ fun withOptions(modifier: Consumer): EventService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun backfills(): BackfillService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun volume(): VolumeService.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt index 96d616787..51cca0969 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt @@ -31,6 +31,11 @@ import com.withorb.api.services.blocking.events.VolumeServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class EventServiceImpl internal constructor(private val clientOptions: ClientOptions) : EventService { @@ -47,8 +52,18 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): EventService = EventServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun backfills(): BackfillService = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun volume(): VolumeService = volume override fun update( @@ -100,8 +115,18 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun backfills(): BackfillService.WithRawResponse = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun volume(): VolumeService.WithRawResponse = volume private val updateHandler: Handler = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt index 87b8a6fc1..1be4cc470 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt @@ -10,6 +10,13 @@ import com.withorb.api.models.InvoiceLineItemCreateParams import com.withorb.api.models.InvoiceLineItemCreateResponse import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceLineItemService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt index b6202b351..5d2f79eb3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt @@ -19,6 +19,13 @@ import com.withorb.api.models.InvoiceLineItemCreateParams import com.withorb.api.models.InvoiceLineItemCreateResponse import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceLineItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceLineItemService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt index 7d689c82a..e44bd7154 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceService.kt @@ -14,6 +14,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPage import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceListSummaryPage @@ -24,6 +26,13 @@ import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceService { /** @@ -48,13 +57,13 @@ interface InvoiceService { ): Invoice /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and - * `invoice_date` properties on an invoice. If you pass null for the metadata value, it will - * clear any existing metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` properties on an invoice. If you pass null for the metadata value, it + * will clear any existing metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can - * only be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, + * `invoice_date`, and `auto_collection` can only be modified if the invoice is in a `draft` + * state. `invoice_date` can only be modified for non-subscription invoices. */ fun update(invoiceId: String): Invoice = update(invoiceId, InvoiceUpdateParams.none()) @@ -215,6 +224,50 @@ interface InvoiceService { fun issue(invoiceId: String, requestOptions: RequestOptions): Invoice = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * This endpoint allows an eligible invoice to be issued manually. This is only possible with + * invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` + * is a time in the past. Issuing an invoice could possibly trigger side effects, some of which + * could be customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice + * to external providers, etc). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice + * summary without any line item details. + */ + fun issueSummary(invoiceId: String): InvoiceIssueSummaryResponse = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InvoiceIssueSummaryResponse = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + ): InvoiceIssueSummaryResponse = issueSummary(invoiceId, params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InvoiceIssueSummaryResponse + + /** @see issueSummary */ + fun issueSummary(params: InvoiceIssueSummaryParams): InvoiceIssueSummaryResponse = + issueSummary(params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): InvoiceIssueSummaryResponse = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * This is a lighter-weight endpoint that returns a list of all * [`Invoice`](/core-concepts#invoice) summaries for an account in a list format. @@ -563,6 +616,53 @@ interface InvoiceService { fun issue(invoiceId: String, requestOptions: RequestOptions): HttpResponseFor = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /invoices/summary/{invoice_id}/issue`, but is + * otherwise the same as [InvoiceService.issueSummary]. + */ + @MustBeClosed + fun issueSummary(invoiceId: String): HttpResponseFor = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none()) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + ): HttpResponseFor = + issueSummary(invoiceId, params, RequestOptions.none()) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + params: InvoiceIssueSummaryParams + ): HttpResponseFor = + issueSummary(params, RequestOptions.none()) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices/summary`, but is otherwise the same as * [InvoiceService.listSummary]. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt index 38ee69982..6c4d9fec9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt @@ -24,6 +24,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPage import com.withorb.api.models.InvoiceListPageResponse import com.withorb.api.models.InvoiceListParams @@ -37,6 +39,13 @@ import com.withorb.api.models.InvoiceVoidInvoiceParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceService { @@ -84,6 +93,13 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO // post /invoices/{invoice_id}/issue withRawResponse().issue(params, requestOptions).parse() + override fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): InvoiceIssueSummaryResponse = + // post /invoices/summary/{invoice_id}/issue + withRawResponse().issueSummary(params, requestOptions).parse() + override fun listSummary( params: InvoiceListSummaryParams, requestOptions: RequestOptions, @@ -325,6 +341,37 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO } } + private val issueSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("invoices", "summary", params._pathParam(0), "issue") + .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 { issueSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val listSummaryHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt index 44484d718..c04fd04ff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt @@ -15,6 +15,11 @@ import com.withorb.api.models.ItemListParams import com.withorb.api.models.ItemUpdateParams import java.util.function.Consumer +/** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for invoices + * and tax calculation purposes. + */ interface ItemService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt index 8378b6a89..50f3624cb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt @@ -27,6 +27,11 @@ import com.withorb.api.models.ItemUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for invoices + * and tax calculation purposes. + */ class ItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : ItemService { private val withRawResponse: ItemService.WithRawResponse by lazy { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt new file mode 100644 index 000000000..ea030c297 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt @@ -0,0 +1,338 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPage +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.blocking.licenses.ExternalLicenseService +import com.withorb.api.services.blocking.licenses.UsageService +import java.util.function.Consumer + +interface LicenseService { + + /** + * 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): LicenseService + + fun externalLicenses(): ExternalLicenseService + + fun usage(): UsageService + + /** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified + * date in the customer's timezone. Otherwise, the activation time will default to the **start** + * of the current day in the customer's timezone. + */ + fun create(params: LicenseCreateParams): LicenseCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseCreateResponse + + /** This endpoint is used to fetch a license given an identifier. */ + fun retrieve(licenseId: String): LicenseRetrieveResponse = + retrieve(licenseId, LicenseRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveResponse = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + ): LicenseRetrieveResponse = retrieve(licenseId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: LicenseRetrieveParams): LicenseRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(licenseId: String, requestOptions: RequestOptions): LicenseRetrieveResponse = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** This endpoint returns a list of all licenses for a subscription. */ + fun list(params: LicenseListParams): LicenseListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseListPage + + /** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** + * of the current day in the customer's timezone. + */ + fun deactivate(licenseId: String): LicenseDeactivateResponse = + deactivate(licenseId, LicenseDeactivateParams.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseDeactivateResponse = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + ): LicenseDeactivateResponse = deactivate(licenseId, params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseDeactivateResponse + + /** @see deactivate */ + fun deactivate(params: LicenseDeactivateParams): LicenseDeactivateResponse = + deactivate(params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate(licenseId: String, requestOptions: RequestOptions): LicenseDeactivateResponse = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** This endpoint is used to fetch a license given an external license identifier. */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + ): LicenseRetrieveByExternalIdResponse = + retrieveByExternalId(externalLicenseId, params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveByExternalIdResponse = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams + ): LicenseRetrieveByExternalIdResponse = retrieveByExternalId(params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveByExternalIdResponse + + /** A view of [LicenseService] 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): LicenseService.WithRawResponse + + fun externalLicenses(): ExternalLicenseService.WithRawResponse + + fun usage(): UsageService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /licenses`, but is otherwise the same as + * [LicenseService.create]. + */ + @MustBeClosed + fun create(params: LicenseCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}`, but is otherwise the same + * as [LicenseService.retrieve]. + */ + @MustBeClosed + fun retrieve(licenseId: String): HttpResponseFor = + retrieve(licenseId, LicenseRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + ): HttpResponseFor = + retrieve(licenseId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: LicenseRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /licenses`, but is otherwise the same as + * [LicenseService.list]. + */ + @MustBeClosed + fun list(params: LicenseListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /licenses/{license_id}/deactivate`, but is + * otherwise the same as [LicenseService.deactivate]. + */ + @MustBeClosed + fun deactivate(licenseId: String): HttpResponseFor = + deactivate(licenseId, LicenseDeactivateParams.none()) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + ): HttpResponseFor = + deactivate(licenseId, params, RequestOptions.none()) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + params: LicenseDeactivateParams + ): HttpResponseFor = deactivate(params, RequestOptions.none()) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /licenses/external_license_id/{external_license_id}`, but is otherwise the same as + * [LicenseService.retrieveByExternalId]. + */ + @MustBeClosed + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + ): HttpResponseFor = + retrieveByExternalId(externalLicenseId, params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + @MustBeClosed + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + @MustBeClosed + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams + ): HttpResponseFor = + retrieveByExternalId(params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + @MustBeClosed + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt new file mode 100644 index 000000000..e3b548f3d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt @@ -0,0 +1,269 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPage +import com.withorb.api.models.LicenseListPageResponse +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.blocking.licenses.ExternalLicenseService +import com.withorb.api.services.blocking.licenses.ExternalLicenseServiceImpl +import com.withorb.api.services.blocking.licenses.UsageService +import com.withorb.api.services.blocking.licenses.UsageServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class LicenseServiceImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseService { + + private val withRawResponse: LicenseService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val externalLicenses: ExternalLicenseService by lazy { + ExternalLicenseServiceImpl(clientOptions) + } + + private val usage: UsageService by lazy { UsageServiceImpl(clientOptions) } + + override fun withRawResponse(): LicenseService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LicenseService = + LicenseServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun externalLicenses(): ExternalLicenseService = externalLicenses + + override fun usage(): UsageService = usage + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): LicenseCreateResponse = + // post /licenses + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): LicenseRetrieveResponse = + // get /licenses/{license_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: LicenseListParams, requestOptions: RequestOptions): LicenseListPage = + // get /licenses + withRawResponse().list(params, requestOptions).parse() + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): LicenseDeactivateResponse = + // post /licenses/{license_id}/deactivate + withRawResponse().deactivate(params, requestOptions).parse() + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): LicenseRetrieveByExternalIdResponse = + // get /licenses/external_license_id/{external_license_id} + withRawResponse().retrieveByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val externalLicenses: ExternalLicenseService.WithRawResponse by lazy { + ExternalLicenseServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val usage: UsageService.WithRawResponse by lazy { + UsageServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): LicenseService.WithRawResponse = + LicenseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun externalLicenses(): ExternalLicenseService.WithRawResponse = externalLicenses + + override fun usage(): UsageService.WithRawResponse = usage + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .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 { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0)) + .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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .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 { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseListPage.builder() + .service(LicenseServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val deactivateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "deactivate") + .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 { deactivateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_license_id", params._pathParam(0)) + .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 { retrieveByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt new file mode 100644 index 000000000..108c63fd2 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPage +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse +import java.util.function.Consumer + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +interface LicenseTypeService { + + /** + * 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): LicenseTypeService + + /** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun create(params: LicenseTypeCreateParams): LicenseTypeCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeCreateResponse + + /** + * This endpoint returns a license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ + fun retrieve(licenseTypeId: String): LicenseTypeRetrieveResponse = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeRetrieveResponse = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + ): LicenseTypeRetrieveResponse = retrieve(licenseTypeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: LicenseTypeRetrieveParams): LicenseTypeRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): LicenseTypeRetrieveResponse = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * This endpoint returns a list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun list(): LicenseTypeListPage = list(LicenseTypeListParams.none()) + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeListPage + + /** @see list */ + fun list(params: LicenseTypeListParams = LicenseTypeListParams.none()): LicenseTypeListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): LicenseTypeListPage = + list(LicenseTypeListParams.none(), requestOptions) + + /** + * A view of [LicenseTypeService] 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 + ): LicenseTypeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /license_types`, but is otherwise the same as + * [LicenseTypeService.create]. + */ + @MustBeClosed + fun create(params: LicenseTypeCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /license_types/{license_type_id}`, but is otherwise + * the same as [LicenseTypeService.retrieve]. + */ + @MustBeClosed + fun retrieve(licenseTypeId: String): HttpResponseFor = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + ): HttpResponseFor = + retrieve(licenseTypeId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LicenseTypeRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /license_types`, but is otherwise the same as + * [LicenseTypeService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(LicenseTypeListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(LicenseTypeListParams.none(), requestOptions) + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt new file mode 100644 index 000000000..0d5e35c45 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPage +import com.withorb.api.models.LicenseTypeListPageResponse +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeService { + + private val withRawResponse: LicenseTypeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LicenseTypeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LicenseTypeService = + LicenseTypeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): LicenseTypeCreateResponse = + // post /license_types + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): LicenseTypeRetrieveResponse = + // get /license_types/{license_type_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): LicenseTypeListPage = + // get /license_types + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): LicenseTypeService.WithRawResponse = + LicenseTypeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .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 { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseTypeId", params.licenseTypeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types", params._pathParam(0)) + .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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .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 { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseTypeListPage.builder() + .service(LicenseTypeServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt index 27b8d7532..a7d8d5c95 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt @@ -14,6 +14,10 @@ import com.withorb.api.models.MetricListParams import com.withorb.api.models.MetricUpdateParams import java.util.function.Consumer +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ interface MetricService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt index 91855682b..2dbcc1477 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.models.MetricUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ class MetricServiceImpl internal constructor(private val clientOptions: ClientOptions) : MetricService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt index 8bbdb710b..29060d8e2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanService.kt @@ -16,6 +16,11 @@ import com.withorb.api.services.blocking.plans.ExternalPlanIdService import com.withorb.api.services.blocking.plans.MigrationService import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface PlanService { /** @@ -30,8 +35,18 @@ interface PlanService { */ fun withOptions(modifier: Consumer): PlanService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun migrations(): MigrationService /** This endpoint allows creation of plans including their prices. */ @@ -146,8 +161,18 @@ interface PlanService { */ fun withOptions(modifier: Consumer): PlanService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun migrations(): MigrationService.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt index c279f8f85..347869694 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt @@ -30,6 +30,11 @@ import com.withorb.api.services.blocking.plans.MigrationServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class PlanServiceImpl internal constructor(private val clientOptions: ClientOptions) : PlanService { private val withRawResponse: PlanService.WithRawResponse by lazy { @@ -47,8 +52,18 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): PlanService = PlanServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdService = externalPlanId + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun migrations(): MigrationService = migrations override fun create(params: PlanCreateParams, requestOptions: RequestOptions): Plan = @@ -88,8 +103,18 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdService.WithRawResponse = externalPlanId + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun migrations(): MigrationService.WithRawResponse = migrations private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt index 15877052b..2714b1744 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt @@ -6,6 +6,32 @@ import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.ClientOptions import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.NewFloatingBulkPrice +import com.withorb.api.models.NewFloatingBulkWithProrationPrice +import com.withorb.api.models.NewFloatingCumulativeGroupedBulkPrice +import com.withorb.api.models.NewFloatingGroupedAllocationPrice +import com.withorb.api.models.NewFloatingGroupedTieredPackagePrice +import com.withorb.api.models.NewFloatingGroupedTieredPrice +import com.withorb.api.models.NewFloatingGroupedWithMeteredMinimumPrice +import com.withorb.api.models.NewFloatingGroupedWithProratedMinimumPrice +import com.withorb.api.models.NewFloatingMatrixPrice +import com.withorb.api.models.NewFloatingMatrixWithAllocationPrice +import com.withorb.api.models.NewFloatingMatrixWithDisplayNamePrice +import com.withorb.api.models.NewFloatingMaxGroupTieredPackagePrice +import com.withorb.api.models.NewFloatingMinimumCompositePrice +import com.withorb.api.models.NewFloatingPackagePrice +import com.withorb.api.models.NewFloatingPackageWithAllocationPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithTieredPricingPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithUnitPricingPrice +import com.withorb.api.models.NewFloatingThresholdTotalAmountPrice +import com.withorb.api.models.NewFloatingTieredPackagePrice +import com.withorb.api.models.NewFloatingTieredPackageWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredPrice +import com.withorb.api.models.NewFloatingTieredWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredWithProrationPrice +import com.withorb.api.models.NewFloatingUnitPrice +import com.withorb.api.models.NewFloatingUnitWithPercentPrice +import com.withorb.api.models.NewFloatingUnitWithProrationPrice import com.withorb.api.models.Price import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams @@ -21,6 +47,18 @@ import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.blocking.prices.ExternalPriceIdService import java.util.function.Consumer +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface PriceService { /** @@ -35,6 +73,18 @@ interface PriceService { */ fun withOptions(modifier: Consumer): PriceService + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdService /** @@ -57,6 +107,374 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): Price + /** @see create */ + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + fun create(body: PriceCreateParams.Body): Price = create(body, RequestOptions.none()) + + /** @see create */ + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + fun create(unit: NewFloatingUnitPrice): Price = create(unit, RequestOptions.none()) + + /** @see create */ + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + fun create(tiered: NewFloatingTieredPrice): Price = create(tiered, RequestOptions.none()) + + /** @see create */ + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + fun create(bulk: NewFloatingBulkPrice): Price = create(bulk, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + fun create(bulkWithFilters: PriceCreateParams.Body.BulkWithFilters): Price = + create(bulkWithFilters, RequestOptions.none()) + + /** @see create */ + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + fun create(package_: NewFloatingPackagePrice): Price = create(package_, RequestOptions.none()) + + /** @see create */ + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + fun create(matrix: NewFloatingMatrixPrice): Price = create(matrix, RequestOptions.none()) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), requestOptions) + + /** @see create */ + fun create(thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice): Price = + create(thresholdTotalAmount, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + fun create(tieredPackage: NewFloatingTieredPackagePrice): Price = + create(tieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + fun create(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): Price = + create(tieredWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + fun create(groupedTiered: NewFloatingGroupedTieredPrice): Price = + create(groupedTiered, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + fun create(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice): Price = + create(tieredPackageWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + fun create(packageWithAllocation: NewFloatingPackageWithAllocationPrice): Price = + create(packageWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + fun create(unitWithPercent: NewFloatingUnitWithPercentPrice): Price = + create(unitWithPercent, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), requestOptions) + + /** @see create */ + fun create(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice): Price = + create(matrixWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), requestOptions) + + /** @see create */ + fun create(tieredWithProration: NewFloatingTieredWithProrationPrice): Price = + create(tieredWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + fun create(unitWithProration: NewFloatingUnitWithProrationPrice): Price = + create(unitWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + fun create(groupedAllocation: NewFloatingGroupedAllocationPrice): Price = + create(groupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + fun create(bulkWithProration: NewFloatingBulkWithProrationPrice): Price = + create(bulkWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + fun create(groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice): Price = + create(groupedWithProratedMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + fun create(groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice): Price = + create(groupedWithMeteredMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds + ): Price = create(groupedWithMinMaxThresholds, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + fun create(matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice): Price = + create(matrixWithDisplayName, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), requestOptions) + + /** @see create */ + fun create(groupedTieredPackage: NewFloatingGroupedTieredPackagePrice): Price = + create(groupedTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice): Price = + create(maxGroupTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice + ): Price = create(scalableMatrixWithUnitPricing, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice + ): Price = create(scalableMatrixWithTieredPricing, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + fun create(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice): Price = + create(cumulativeGroupedBulk, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation + ): Price = create(cumulativeGroupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + fun create(minimumComposite: NewFloatingMinimumCompositePrice): Price = + create(minimumComposite, RequestOptions.none()) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + fun create(percent: PriceCreateParams.Body.Percent): Price = + create(percent, RequestOptions.none()) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + + /** @see create */ + fun create(eventOutput: PriceCreateParams.Body.EventOutput): Price = + create(eventOutput, RequestOptions.none()) + /** * This endpoint allows you to update the `metadata` property on a price. If you pass null for * the metadata value, it will clear any existing metadata for that price. @@ -248,6 +666,18 @@ interface PriceService { */ fun withOptions(modifier: Consumer): PriceService.WithRawResponse + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdService.WithRawResponse /** @@ -265,6 +695,483 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see create */ + @MustBeClosed + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(body: PriceCreateParams.Body): HttpResponseFor = + create(body, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(unit: NewFloatingUnitPrice): HttpResponseFor = + create(unit, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(tiered: NewFloatingTieredPrice): HttpResponseFor = + create(tiered, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(bulk: NewFloatingBulkPrice): HttpResponseFor = + create(bulk, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters + ): HttpResponseFor = create(bulkWithFilters, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(package_: NewFloatingPackagePrice): HttpResponseFor = + create(package_, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(matrix: NewFloatingMatrixPrice): HttpResponseFor = + create(matrix, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice + ): HttpResponseFor = create(thresholdTotalAmount, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(tieredPackage: NewFloatingTieredPackagePrice): HttpResponseFor = + create(tieredPackage, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): HttpResponseFor = + create(tieredWithMinimum, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(groupedTiered: NewFloatingGroupedTieredPrice): HttpResponseFor = + create(groupedTiered, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice + ): HttpResponseFor = create(tieredPackageWithMinimum, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ): HttpResponseFor = create(packageWithAllocation, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(unitWithPercent: NewFloatingUnitWithPercentPrice): HttpResponseFor = + create(unitWithPercent, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): HttpResponseFor = create(matrixWithAllocation, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice + ): HttpResponseFor = create(tieredWithProration, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(unitWithProration: NewFloatingUnitWithProrationPrice): HttpResponseFor = + create(unitWithProration, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(groupedAllocation: NewFloatingGroupedAllocationPrice): HttpResponseFor = + create(groupedAllocation, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(bulkWithProration: NewFloatingBulkWithProrationPrice): HttpResponseFor = + create(bulkWithProration, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice + ): HttpResponseFor = create(groupedWithProratedMinimum, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice + ): HttpResponseFor = create(groupedWithMeteredMinimum, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds + ): HttpResponseFor = create(groupedWithMinMaxThresholds, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + ): HttpResponseFor = create(matrixWithDisplayName, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice + ): HttpResponseFor = create(groupedTieredPackage, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): HttpResponseFor = create(maxGroupTieredPackage, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice + ): HttpResponseFor = create(scalableMatrixWithUnitPricing, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice + ): HttpResponseFor = create(scalableMatrixWithTieredPricing, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice + ): HttpResponseFor = create(cumulativeGroupedBulk, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation + ): HttpResponseFor = create(cumulativeGroupedAllocation, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(minimumComposite: NewFloatingMinimumCompositePrice): HttpResponseFor = + create(minimumComposite, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(percent: PriceCreateParams.Body.Percent): HttpResponseFor = + create(percent, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(eventOutput: PriceCreateParams.Body.EventOutput): HttpResponseFor = + create(eventOutput, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the same as * [PriceService.update]. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt index f880d0f39..47636a3f0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt @@ -34,6 +34,18 @@ import com.withorb.api.services.blocking.prices.ExternalPriceIdServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class PriceServiceImpl internal constructor(private val clientOptions: ClientOptions) : PriceService { @@ -50,6 +62,18 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): PriceService = PriceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdService = externalPriceId override fun create(params: PriceCreateParams, requestOptions: RequestOptions): Price = @@ -106,6 +130,18 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdService.WithRawResponse = externalPriceId private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt index b4c642cef..75cd84e63 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt @@ -13,6 +13,11 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanVersion import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface ExternalPlanIdService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt index c6c1c9f1d..90ac53eae 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt @@ -24,6 +24,11 @@ import com.withorb.api.models.PlanVersion import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt index 3fbca7cee..0027ee274 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt @@ -10,6 +10,12 @@ import com.withorb.api.models.CouponSubscriptionListPage import com.withorb.api.models.CouponSubscriptionListParams import java.util.function.Consumer +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface SubscriptionService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt index 7b05ab124..086f4f253 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt @@ -21,6 +21,12 @@ import com.withorb.api.models.Subscriptions import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt index cd88ed57e..454c48523 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt @@ -12,6 +12,24 @@ import com.withorb.api.models.CustomerBalanceTransactionListPage import com.withorb.api.models.CustomerBalanceTransactionListParams import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface BalanceTransactionService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt index 581300c3a..40842c9fb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt @@ -24,6 +24,24 @@ import com.withorb.api.models.CustomerBalanceTransactionListParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class BalanceTransactionServiceImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt index bab452f94..c673e8d59 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostService.kt @@ -12,6 +12,24 @@ import com.withorb.api.models.CustomerCostListParams import com.withorb.api.models.CustomerCostListResponse import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CostService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt index 9eedcf79f..18b17721f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt @@ -22,6 +22,24 @@ import com.withorb.api.models.CustomerCostListResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CostServiceImpl internal constructor(private val clientOptions: ClientOptions) : CostService { private val withRawResponse: CostService.WithRawResponse by lazy { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt index 3b33b59ad..4af1d232b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt @@ -14,6 +14,10 @@ import com.withorb.api.services.blocking.customers.credits.LedgerService import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditService { /** @@ -28,8 +32,16 @@ interface CreditService { */ fun withOptions(modifier: Consumer): CreditService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpService /** @@ -40,6 +52,11 @@ interface CreditService { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun list(customerId: String): CustomerCreditListPage = list(customerId, CustomerCreditListParams.none()) @@ -80,6 +97,11 @@ interface CreditService { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun listByExternalId(externalCustomerId: String): CustomerCreditListByExternalIdPage = listByExternalId(externalCustomerId, CustomerCreditListByExternalIdParams.none()) @@ -134,8 +156,16 @@ interface CreditService { */ fun withOptions(modifier: Consumer): CreditService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpService.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt index ae2dfe22c..99bb263ad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt @@ -28,6 +28,10 @@ import com.withorb.api.services.blocking.customers.credits.TopUpServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditService { @@ -44,8 +48,16 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): CreditService = CreditServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerService = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpService = topUps override fun list( @@ -83,8 +95,16 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerService.WithRawResponse = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpService.WithRawResponse = topUps private val listHandler: Handler = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt index c72bb7243..03c3a4adf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerService.kt @@ -16,6 +16,10 @@ import com.withorb.api.models.CustomerCreditLedgerListPage import com.withorb.api.models.CustomerCreditLedgerListParams import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface LedgerService { /** @@ -54,10 +58,8 @@ interface LedgerService { * * As usage for a customer is reported into Orb, credits may be deducted according to the * customer's plan configuration. An automated deduction of this type will result in a ledger - * entry, also with a starting and ending balance. In order to provide better tracing - * capabilities for automatic deductions, Orb always associates each automatic deduction with - * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place - * and to ensure that credits are never deducted without an associated usage event. + * entry, also with a starting and ending balance. Each day's usage for a particular price, + * invoice, and block will be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring * credit block* first in order to ensure that all credits are utilized appropriately. As an @@ -176,7 +178,13 @@ interface LedgerService { * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying - * the cost basis with the number of credit units added. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. @@ -300,7 +308,13 @@ interface LedgerService { * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying - * the cost basis with the number of credit units added. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. @@ -409,10 +423,8 @@ interface LedgerService { * * As usage for a customer is reported into Orb, credits may be deducted according to the * customer's plan configuration. An automated deduction of this type will result in a ledger - * entry, also with a starting and ending balance. In order to provide better tracing - * capabilities for automatic deductions, Orb always associates each automatic deduction with - * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place - * and to ensure that credits are never deducted without an associated usage event. + * entry, also with a starting and ending balance. Each day's usage for a particular price, + * invoice, and block will be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring * credit block* first in order to ensure that all credits are utilized appropriately. As an diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt index d1e4410ff..c227918a0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt @@ -29,6 +29,10 @@ import com.withorb.api.models.CustomerCreditLedgerListParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOptions) : LedgerService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt index 429b2af1f..83b77e7cf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt @@ -19,6 +19,10 @@ import com.withorb.api.models.CustomerCreditTopUpListPage import com.withorb.api.models.CustomerCreditTopUpListParams import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface TopUpService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt index 80592386d..a9965b21c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt @@ -32,6 +32,10 @@ import com.withorb.api.models.CustomerCreditTopUpListParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOptions) : TopUpService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt index 954b6375c..9d3544e53 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillService.kt @@ -18,6 +18,11 @@ import com.withorb.api.models.EventBackfillRevertParams import com.withorb.api.models.EventBackfillRevertResponse import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface BackfillService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt index 4e5f90e1b..8f64789ea 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt @@ -30,6 +30,11 @@ import com.withorb.api.models.EventBackfillRevertResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class BackfillServiceImpl internal constructor(private val clientOptions: ClientOptions) : BackfillService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt index 357dfcaf5..2cdd25092 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt @@ -10,6 +10,11 @@ import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface VolumeService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt index 5f8b4f8f5..0e1688540 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt @@ -18,6 +18,11 @@ import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class VolumeServiceImpl internal constructor(private val clientOptions: ClientOptions) : VolumeService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt new file mode 100644 index 000000000..1356c2da5 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse +import java.util.function.Consumer + +interface ExternalLicenseService { + + /** + * 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): ExternalLicenseService + + /** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + ): LicenseExternalLicenseGetUsageResponse = + getUsage(externalLicenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseExternalLicenseGetUsageResponse = + getUsage(params.toBuilder().externalLicenseId(externalLicenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams + ): LicenseExternalLicenseGetUsageResponse = getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseExternalLicenseGetUsageResponse + + /** + * A view of [ExternalLicenseService] 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 + ): ExternalLicenseService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /licenses/external_licenses/{external_license_id}/usage`, but is otherwise the same as + * [ExternalLicenseService.getUsage]. + */ + @MustBeClosed + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + ): HttpResponseFor = + getUsage(externalLicenseId, params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getUsage( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseExternalLicenseGetUsageParams + ): HttpResponseFor = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt new file mode 100644 index 000000000..58963b23c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExternalLicenseServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseService { + + private val withRawResponse: ExternalLicenseService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExternalLicenseService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ExternalLicenseService = + ExternalLicenseServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): LicenseExternalLicenseGetUsageResponse = + // get /licenses/external_licenses/{external_license_id}/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ExternalLicenseService.WithRawResponse = + ExternalLicenseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_licenses", params._pathParam(0), "usage") + .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 { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt new file mode 100644 index 000000000..2a3f5ea9e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse +import java.util.function.Consumer + +interface UsageService { + + /** + * 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): UsageService + + /** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ + fun getAllUsage(params: LicenseUsageGetAllUsageParams): LicenseUsageGetAllUsageResponse = + getAllUsage(params, RequestOptions.none()) + + /** @see getAllUsage */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetAllUsageResponse + + /** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage(licenseId: String): LicenseUsageGetUsageResponse = + getUsage(licenseId, LicenseUsageGetUsageParams.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetUsageResponse = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + ): LicenseUsageGetUsageResponse = getUsage(licenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetUsageResponse + + /** @see getUsage */ + fun getUsage(params: LicenseUsageGetUsageParams): LicenseUsageGetUsageResponse = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage(licenseId: String, requestOptions: RequestOptions): LicenseUsageGetUsageResponse = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + + /** A view of [UsageService] 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): UsageService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /licenses/usage`, but is otherwise the same as + * [UsageService.getAllUsage]. + */ + @MustBeClosed + fun getAllUsage( + params: LicenseUsageGetAllUsageParams + ): HttpResponseFor = + getAllUsage(params, RequestOptions.none()) + + /** @see getAllUsage */ + @MustBeClosed + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}/usage`, but is otherwise the + * same as [UsageService.getUsage]. + */ + @MustBeClosed + fun getUsage(licenseId: String): HttpResponseFor = + getUsage(licenseId, LicenseUsageGetUsageParams.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + ): HttpResponseFor = + getUsage(licenseId, params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseUsageGetUsageParams + ): HttpResponseFor = getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt new file mode 100644 index 000000000..fac19c82b --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class UsageServiceImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService { + + private val withRawResponse: UsageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UsageService = + UsageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): LicenseUsageGetAllUsageResponse = + // get /licenses/usage + withRawResponse().getAllUsage(params, requestOptions).parse() + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): LicenseUsageGetUsageResponse = + // get /licenses/{license_id}/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UsageService.WithRawResponse = + UsageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getAllUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "usage") + .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 { getAllUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "usage") + .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 { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt index 0770d8637..08bf02890 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdService.kt @@ -11,6 +11,11 @@ import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface ExternalPlanIdService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt index 632faabfd..504d8dab2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt @@ -22,6 +22,11 @@ import com.withorb.api.models.PlanExternalPlanIdUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt index 19dc5cbd5..d2c1e4a61 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt @@ -14,6 +14,11 @@ import com.withorb.api.models.PlanMigrationRetrieveParams import com.withorb.api.models.PlanMigrationRetrieveResponse import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface MigrationService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt index 1dd143277..83d679507 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt @@ -26,6 +26,11 @@ import com.withorb.api.models.PlanMigrationRetrieveResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class MigrationServiceImpl internal constructor(private val clientOptions: ClientOptions) : MigrationService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt index 6b6feccb9..e7731b31a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt @@ -11,6 +11,18 @@ import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams import java.util.function.Consumer +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface ExternalPriceIdService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt index af5d6859f..bd02969d1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt @@ -22,6 +22,18 @@ import com.withorb.api.models.PriceExternalPriceIdUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class ExternalPriceIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdService { diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt b/orb-java-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt index 4dd94b267..97c34c8f5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt @@ -15,25 +15,12 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { } catch (e: Exception) { throw RuntimeException( """ - The test suite will not run without a mock Prism server running against your OpenAPI spec. + The test suite will not run without a mock server running against your OpenAPI spec. You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests that require the mock server. - To fix: - - 1. Install Prism (requires Node 16+): - - With npm: - $ npm install -g @stoplight/prism-cli - - With yarn: - $ yarn global add @stoplight/prism-cli - - 2. Run the mock server - - To run the server, pass in the path of your OpenAPI spec to the prism command: - $ prism mock path/to/your.openapi.yml + To fix run `./scripts/mock` in a separate terminal. """ .trimIndent(), e, diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt index a8bc18d22..0538190b8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt @@ -3,12 +3,14 @@ package com.withorb.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDate +import java.time.LocalTime import java.time.OffsetDateTime +import java.time.ZoneOffset import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource import org.junitpioneer.jupiter.cartesian.CartesianTest @@ -72,11 +74,34 @@ internal class ObjectMappersTest { } } - enum class LenientOffsetDateTimeTestCase(val string: String) { - DATE("1998-04-21"), - DATE_TIME("1998-04-21T04:00:00"), - ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), - ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + enum class LenientOffsetDateTimeTestCase( + val string: String, + val expectedOffsetDateTime: OffsetDateTime, + ) { + DATE( + "1998-04-21", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(0, 0), ZoneOffset.UTC), + ), + DATE_TIME( + "1998-04-21T04:00:00", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(4, 0), ZoneOffset.UTC), + ), + ZONED_DATE_TIME_1( + "1998-04-21T04:00:00+03:00", + expectedOffsetDateTime = + OffsetDateTime.of( + LocalDate.of(1998, 4, 21), + LocalTime.of(4, 0), + ZoneOffset.ofHours(3), + ), + ), + ZONED_DATE_TIME_2( + "1998-04-21T04:00:00Z", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(4, 0), ZoneOffset.UTC), + ), } @ParameterizedTest @@ -85,6 +110,8 @@ internal class ObjectMappersTest { val jsonMapper = jsonMapper() val json = jsonMapper.writeValueAsString(testCase.string) - assertDoesNotThrow { jsonMapper().readValue(json) } + val offsetDateTime = jsonMapper().readValue(json) + + assertThat(offsetDateTime).isEqualTo(testCase.expectedOffsetDateTime) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt new file mode 100644 index 000000000..b7a705e1d --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt @@ -0,0 +1,739 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core.http + +import com.withorb.api.core.MultipartField +import com.withorb.api.core.jsonMapper +import java.io.ByteArrayOutputStream +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HttpRequestBodiesTest { + + @Test + fun multipartFormData_serializesFieldWithFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "file" to + MultipartField.builder() + .value("hello") + .filename("hello.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = body.contentType()!!.substringAfter("multipart/form-data; boundary=") + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="file"; filename="hello.txt" + |Content-Type: text/plain + | + |hello + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesFieldWithoutFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("value") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStream() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "stream content".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |stream content + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesByteArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "binary" to + MultipartField.builder() + .value("abc".toByteArray()) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="binary" + |Content-Type: application/octet-stream + | + |abc + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesBooleanValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "flag" to + MultipartField.builder() + .value(true) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="flag" + |Content-Type: text/plain + | + |true + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNumberValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "count" to + MultipartField.builder().value(42).contentType("text/plain").build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="count" + |Content-Type: text/plain + | + |42 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNullValueAsNoParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "present" to + MultipartField.builder() + .value("yes") + .contentType("text/plain") + .build(), + "absent" to + MultipartField.builder() + .value(null as String?) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="present" + |Content-Type: text/plain + | + |yes + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "items" to + MultipartField.builder>() + .value(listOf("alpha", "beta", "gamma")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |alpha + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |beta + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |gamma + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesObjectAsNestedParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "meta" to + MultipartField.builder>() + .value(mapOf("key1" to "val1", "key2" to "val2")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="meta[key1]" + |Content-Type: text/plain + | + |val1 + |--$boundary + |Content-Disposition: form-data; name="meta[key2]" + |Content-Type: text/plain + | + |val2 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesMultipleFields() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "name" to + MultipartField.builder() + .value("Alice") + .contentType("text/plain") + .build(), + "age" to + MultipartField.builder().value(30).contentType("text/plain").build(), + "file" to + MultipartField.builder() + .value("file contents") + .filename("doc.txt") + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="name" + |Content-Type: text/plain + | + |Alice + |--$boundary + |Content-Disposition: form-data; name="age" + |Content-Type: text/plain + | + |30 + |--$boundary + |Content-Disposition: form-data; name="file"; filename="doc.txt" + |Content-Type: text/plain + | + |file contents + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_quotesSpecialCharactersInNameAndFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field\nname" to + MultipartField.builder() + .value("value") + .filename("file\r\"name.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field%0Aname"; filename="file%0D%22name.txt" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_writeIsRepeatable() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("repeatable") + .contentType("text/plain") + .build() + ), + ) + + val output1 = ByteArrayOutputStream() + body.writeTo(output1) + val output2 = ByteArrayOutputStream() + body.writeTo(output2) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output1.size().toLong()) + val boundary = boundary(body) + val expected = + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |repeatable + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + assertThat(output1.toString("UTF-8")).isEqualTo(expected) + assertThat(output2.toString("UTF-8")).isEqualTo(expected) + } + + @Test + fun multipartFormData_serializesByteArrayInputStream() { + // ByteArrayInputStream is specifically handled as repeatable with known content length. + val inputStream = "byte array stream".byteInputStream() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |byte array stream + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStreamWithFilename() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "file data".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "upload" to + MultipartField.builder() + .value(inputStream) + .filename("upload.bin") + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="upload"; filename="upload.bin" + |Content-Type: application/octet-stream + | + |file data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNestedArrayInObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder>>() + .value(mapOf("tags" to listOf("a", "b"))) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data[tags][]" + |Content-Type: text/plain + | + |a + |--$boundary + |Content-Disposition: form-data; name="data[tags][]" + |Content-Type: text/plain + | + |b + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_contentLengthIsUnknownWhenInputStreamPresent() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "text" to + MultipartField.builder() + .value("hello") + .contentType("text/plain") + .build(), + "stream" to + MultipartField.builder() + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the + // non-repeatable code path. + .value("data".byteInputStream().buffered()) + .contentType("application/octet-stream") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="text" + |Content-Type: text/plain + | + |hello + |--$boundary + |Content-Disposition: form-data; name="stream" + |Content-Type: application/octet-stream + | + |data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "items" to + MultipartField.builder>() + .value(emptyList()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "meta" to + MultipartField.builder>() + .value(emptyMap()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + private fun boundary(body: HttpRequestBody): String = + body.contentType()!!.substringAfter("multipart/form-data; boundary=") +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt index 4170f41f5..b7b4d5b46 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt @@ -1,6 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package com.withorb.api.core.http -import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matching +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.resetAllScenarios +import com.github.tomakehurst.wiremock.client.WireMock.serviceUnavailable +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index 49e22110c..5cde73367 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -62,6 +62,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -141,6 +142,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -201,6 +209,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -278,6 +287,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -346,6 +362,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -425,6 +442,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt index f53447480..e66f22733 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,7 +14,9 @@ internal class AlertCreateForSubscriptionParamsTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .pricingUnitId("pricing_unit_id") .build() } @@ -38,14 +41,18 @@ internal class AlertCreateForSubscriptionParamsTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .pricingUnitId("pricing_unit_id") .build() val body = params._body() assertThat(body.thresholds()).containsExactly(Threshold.builder().value(0.0).build()) assertThat(body.type()).isEqualTo(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + assertThat(body.groupingKeys().getOrNull()).containsExactly("string") assertThat(body.metricId()).contains("metric_id") + assertThat(body.pricingUnitId()).contains("pricing_unit_id") } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt index 8221015e9..6d9d31146 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt @@ -44,6 +44,8 @@ internal class AlertListPageResponseTest { .thresholdValue(0.0) .build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) .paginationMetadata( @@ -79,6 +81,8 @@ internal class AlertListPageResponseTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) assertThat(alertListPageResponse.paginationMetadata()) @@ -120,6 +124,8 @@ internal class AlertListPageResponseTest { .thresholdValue(0.0) .build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() ) .paginationMetadata( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt index 8a8fc960b..c2f98f46e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt @@ -40,6 +40,8 @@ internal class AlertTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() assertThat(alert.id()).isEqualTo("XuxCbt7x9L82yyeF") @@ -72,6 +74,8 @@ internal class AlertTest { .containsExactly( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + assertThat(alert.groupingKeys().getOrNull()).containsExactly("string") + assertThat(alert.licenseType()).contains(Alert.LicenseType.builder().id("id").build()) } @Test @@ -104,6 +108,8 @@ internal class AlertTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) .build() val roundtrippedAlert = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt index 5f9611a71..d66705ae7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt @@ -29,6 +29,7 @@ internal class AllocationTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() assertThat(allocation.allowsRollover()).isEqualTo(true) @@ -48,6 +49,7 @@ internal class AllocationTest { .addValue("string") .build() ) + assertThat(allocation.licenseTypeId()).contains("license_type_id") } @Test @@ -70,6 +72,7 @@ internal class AllocationTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() val roundtrippedAllocation = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index 20a36bd30..616885300 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -64,9 +64,76 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit.builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -111,6 +178,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -185,9 +253,77 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -232,6 +368,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -311,9 +448,79 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -360,6 +567,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -434,9 +642,82 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -483,6 +764,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -551,9 +833,76 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit.builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -598,6 +947,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -676,9 +1026,77 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -723,6 +1141,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index d24073fbd..2681913f7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -64,9 +64,84 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -111,6 +186,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -185,9 +261,85 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -232,6 +384,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -315,9 +468,87 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -364,6 +595,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -438,9 +670,87 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -487,6 +797,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -555,9 +866,84 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -602,6 +988,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -680,9 +1067,85 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -727,6 +1190,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt index 34ac805a9..8faa3e42b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -45,6 +46,11 @@ internal class BillableMetricTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() assertThat(billableMetric.id()).isEqualTo("id") @@ -79,6 +85,12 @@ internal class BillableMetricTest { ) assertThat(billableMetric.name()).isEqualTo("name") assertThat(billableMetric.status()).isEqualTo(BillableMetric.Status.ACTIVE) + assertThat(billableMetric.parameterDefinitions().getOrNull()) + .containsExactly( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test @@ -116,6 +128,11 @@ internal class BillableMetricTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val roundtrippedBillableMetric = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index a013bd44b..5890c5be0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -303,6 +303,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -394,6 +395,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -779,6 +787,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -870,6 +879,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1256,6 +1272,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1339,6 +1356,13 @@ internal class ChangedSubscriptionResourcesTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1713,6 +1737,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1796,6 +1821,13 @@ internal class ChangedSubscriptionResourcesTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2196,6 +2228,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2287,6 +2320,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2672,6 +2712,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2763,6 +2804,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt new file mode 100644 index 000000000..a25129148 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditBlockListInvoicesParamsTest { + + @Test + fun create() { + CreditBlockListInvoicesParams.builder().blockId("block_id").build() + } + + @Test + fun pathParams() { + val params = CreditBlockListInvoicesParams.builder().blockId("block_id").build() + + assertThat(params._pathParam(0)).isEqualTo("block_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt new file mode 100644 index 000000000..6f30c53ee --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditBlockListInvoicesResponseTest { + + @Test + fun create() { + val creditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse.builder() + .block( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + .addInvoice( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + .build() + + assertThat(creditBlockListInvoicesResponse.block()) + .isEqualTo( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + assertThat(creditBlockListInvoicesResponse.invoices()) + .containsExactly( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val creditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse.builder() + .block( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + .addInvoice( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + .build() + + val roundtrippedCreditBlockListInvoicesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(creditBlockListInvoicesResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCreditBlockListInvoicesResponse) + .isEqualTo(creditBlockListInvoicesResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt index 68c2b96c9..364ef830f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CreditBlockRetrieveResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CreditBlockRetrieveResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CreditBlockRetrieveResponseTest { .build() ) assertThat(creditBlockRetrieveResponse.maximumInitialBalance()).contains(0.0) + assertThat(creditBlockRetrieveResponse.metadata()) + .isEqualTo( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(creditBlockRetrieveResponse.perUnitCostBasis()).contains("per_unit_cost_basis") assertThat(creditBlockRetrieveResponse.status()) .isEqualTo(CreditBlockRetrieveResponse.Status.ACTIVE) @@ -67,6 +79,11 @@ internal class CreditBlockRetrieveResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CreditBlockRetrieveResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt index 390cc855b..2cf8cd2c2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt @@ -76,6 +76,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -167,6 +168,13 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +246,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -321,6 +330,13 @@ internal class CustomerCostListByExternalIdResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +419,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -494,6 +511,13 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt index c27926b62..ff5de40ee 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt @@ -76,6 +76,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -167,6 +168,13 @@ internal class CustomerCostListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +246,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -321,6 +330,13 @@ internal class CustomerCostListResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +419,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -494,6 +511,13 @@ internal class CustomerCostListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt index 8d29cb30a..1283ee12c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt @@ -47,6 +47,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -115,6 +116,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -169,6 +171,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 0c54e65de..707a9e776 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -335,6 +336,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -690,6 +698,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -786,6 +795,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt index 0cf4b256e..6ece3389c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt @@ -41,6 +41,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -104,6 +105,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -152,6 +154,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 7c3bc0908..afcc9697b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -335,6 +336,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +697,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -785,6 +794,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt index 02d6d0a49..e8d42a435 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageResponseTest.kt @@ -262,6 +262,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -367,6 +368,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -734,6 +742,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -839,6 +848,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1209,6 +1225,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1314,6 +1331,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt index bb3293e9a..357b6ee0f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponseTest.kt @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -335,6 +336,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +697,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -785,6 +794,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt index d58df0af6..05634410d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageResponseTest.kt @@ -262,6 +262,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -367,6 +368,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -734,6 +742,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -839,6 +848,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1209,6 +1225,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1314,6 +1331,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt index 9d7f24e7b..7b69c234b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponseTest.kt @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -335,6 +336,13 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +697,7 @@ internal class CustomerCreditLedgerListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -785,6 +794,13 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt index add48b6d5..b52a00271 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -30,6 +31,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -56,6 +62,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -85,6 +96,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt index c02f88add..a6ee7c823 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,6 +15,10 @@ internal class CustomerCreditListByExternalIdParamsTest { .externalCustomerId("external_customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -38,6 +43,10 @@ internal class CustomerCreditListByExternalIdParamsTest { .externalCustomerId("external_customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -49,6 +58,10 @@ internal class CustomerCreditListByExternalIdParamsTest { QueryParams.builder() .put("currency", "currency") .put("cursor", "cursor") + .put("effective_date[gt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[gte]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lte]", "2019-12-27T18:11:19.117Z") .put("include_all_blocks", "true") .put("limit", "1") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt index ad06a474d..a1b21ef8e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) assertThat(customerCreditListByExternalIdResponse.maximumInitialBalance()).contains(0.0) + assertThat(customerCreditListByExternalIdResponse.metadata()) + .isEqualTo( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(customerCreditListByExternalIdResponse.perUnitCostBasis()) .contains("per_unit_cost_basis") assertThat(customerCreditListByExternalIdResponse.status()) @@ -68,6 +80,11 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt index 86c3c5fce..6164150d2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -28,6 +29,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -52,6 +58,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -79,6 +90,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt index 35a23e2e9..63dceb213 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,6 +15,10 @@ internal class CustomerCreditListParamsTest { .customerId("customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -35,6 +40,10 @@ internal class CustomerCreditListParamsTest { .customerId("customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -46,6 +55,10 @@ internal class CustomerCreditListParamsTest { QueryParams.builder() .put("currency", "currency") .put("cursor", "cursor") + .put("effective_date[gt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[gte]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lte]", "2019-12-27T18:11:19.117Z") .put("include_all_blocks", "true") .put("limit", "1") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt index bb1390080..c0f782d24 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CustomerCreditListResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CustomerCreditListResponseTest { .build() ) assertThat(customerCreditListResponse.maximumInitialBalance()).contains(0.0) + assertThat(customerCreditListResponse.metadata()) + .isEqualTo( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(customerCreditListResponse.perUnitCostBasis()).contains("per_unit_cost_basis") assertThat(customerCreditListResponse.status()) .isEqualTo(CustomerCreditListResponse.Status.ACTIVE) @@ -67,6 +79,11 @@ internal class CustomerCreditListResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index e432581b5..592a6f4a9 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -241,6 +241,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -332,6 +333,13 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -660,6 +668,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -743,6 +752,13 @@ internal class IncrementLedgerEntryTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1080,6 +1096,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1171,6 +1188,13 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index 20399ca1d..0da3b37e3 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt @@ -28,6 +28,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -77,6 +78,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -124,6 +126,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + assertThat(body.autoCollection()).contains(true) assertThat(body.customerId()).contains("4khy3nwzktxv7") assertThat(body.discount()) .contains( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 7b746db93..092d708ea 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt @@ -186,6 +186,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -265,6 +266,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -556,6 +564,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -633,6 +642,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -928,6 +944,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1007,6 +1024,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt new file mode 100644 index 000000000..2a52476ca --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvoiceIssueSummaryParamsTest { + + @Test + fun create() { + InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").synchronous(true).build() + } + + @Test + fun pathParams() { + val params = InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").build() + + assertThat(params._pathParam(0)).isEqualTo("invoice_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").synchronous(true).build() + + val body = params._body() + + assertThat(body.synchronous()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").build() + + val body = params._body() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt new file mode 100644 index 000000000..507c3eeaf --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt @@ -0,0 +1,401 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvoiceIssueSummaryResponseTest { + + @Test + fun create() { + val invoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .billingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + .invoiceSource(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memo("memo") + .metadata( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(InvoiceIssueSummaryResponse.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + + assertThat(invoiceIssueSummaryResponse.id()).isEqualTo("id") + assertThat(invoiceIssueSummaryResponse.amountDue()).isEqualTo("8.00") + assertThat(invoiceIssueSummaryResponse.autoCollection()) + .isEqualTo( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.billingAddress()) + .contains( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(invoiceIssueSummaryResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + assertThat(invoiceIssueSummaryResponse.creditNotes()) + .containsExactly( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.currency()).isEqualTo("USD") + assertThat(invoiceIssueSummaryResponse.customer()) + .isEqualTo( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + assertThat(invoiceIssueSummaryResponse.customerBalanceTransactions()) + .containsExactly( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + assertThat(invoiceIssueSummaryResponse.customerTaxId()) + .contains( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + assertThat(invoiceIssueSummaryResponse.dueDate()) + .contains(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + assertThat(invoiceIssueSummaryResponse.eligibleToIssueAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.hostedInvoiceUrl()).contains("hosted_invoice_url") + assertThat(invoiceIssueSummaryResponse.invoiceDate()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + assertThat(invoiceIssueSummaryResponse.invoiceNumber()).isEqualTo("JYEFHK-00001") + assertThat(invoiceIssueSummaryResponse.invoicePdf()) + .contains("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + assertThat(invoiceIssueSummaryResponse.invoiceSource()) + .isEqualTo(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + assertThat(invoiceIssueSummaryResponse.issueFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.issuedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.memo()).contains("memo") + assertThat(invoiceIssueSummaryResponse.metadata()) + .isEqualTo( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.paidAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.paymentAttempts()) + .containsExactly( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + assertThat(invoiceIssueSummaryResponse.paymentFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.paymentStartedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.scheduledIssueAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.shippingAddress()) + .contains( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(invoiceIssueSummaryResponse.status()) + .isEqualTo(InvoiceIssueSummaryResponse.Status.ISSUED) + assertThat(invoiceIssueSummaryResponse.subscription()) + .contains(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + assertThat(invoiceIssueSummaryResponse.syncFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.total()).isEqualTo("8.00") + assertThat(invoiceIssueSummaryResponse.voidedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.willAutoIssue()).isEqualTo(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .billingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + .invoiceSource(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memo("memo") + .metadata( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(InvoiceIssueSummaryResponse.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + + val roundtrippedInvoiceIssueSummaryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invoiceIssueSummaryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvoiceIssueSummaryResponse).isEqualTo(invoiceIssueSummaryResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt index aaba0feb6..f65103746 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt @@ -87,6 +87,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -161,6 +162,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -266,6 +274,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -340,6 +349,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -451,6 +467,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -525,6 +542,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt index d29aa1314..69cd680d7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceListPageResponseTest.kt @@ -205,6 +205,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -296,6 +297,13 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -586,6 +594,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -669,6 +678,13 @@ internal class InvoiceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -973,6 +989,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1064,6 +1081,13 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt index 632b5b154..ab8b70256 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceTest.kt @@ -182,6 +182,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -261,6 +262,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -543,6 +551,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -620,6 +629,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -904,6 +920,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -983,6 +1000,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt index 5ac0a6683..f8b22c736 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt @@ -13,6 +13,7 @@ internal class InvoiceUpdateParamsTest { fun create() { InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -38,6 +39,7 @@ internal class InvoiceUpdateParamsTest { val params = InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -50,6 +52,7 @@ internal class InvoiceUpdateParamsTest { val body = params._body() + assertThat(body.autoCollection()).contains(true) assertThat(body.dueDate()) .contains(InvoiceUpdateParams.DueDate.ofDate(LocalDate.parse("2023-09-22"))) assertThat(body.invoiceDate()) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt new file mode 100644 index 000000000..6afad4000 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseCreateParamsTest { + + @Test + fun create() { + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + } + + @Test + fun body() { + val params = + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + + val body = params._body() + + assertThat(body.externalLicenseId()).isEqualTo("external_license_id") + assertThat(body.licenseTypeId()).isEqualTo("license_type_id") + assertThat(body.subscriptionId()).isEqualTo("subscription_id") + assertThat(body.endDate()).contains(LocalDate.parse("2026-01-27")) + assertThat(body.startDate()).contains(LocalDate.parse("2026-01-27")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val body = params._body() + + assertThat(body.externalLicenseId()).isEqualTo("external_license_id") + assertThat(body.licenseTypeId()).isEqualTo("license_type_id") + assertThat(body.subscriptionId()).isEqualTo("subscription_id") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt new file mode 100644 index 000000000..a2b9ff432 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseCreateResponseTest { + + @Test + fun create() { + val licenseCreateResponse = + LicenseCreateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseCreateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseCreateResponse.id()).isEqualTo("id") + assertThat(licenseCreateResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseCreateResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseCreateResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseCreateResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseCreateResponse.status()).isEqualTo(LicenseCreateResponse.Status.ACTIVE) + assertThat(licenseCreateResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseCreateResponse = + LicenseCreateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseCreateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseCreateResponse).isEqualTo(licenseCreateResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt new file mode 100644 index 000000000..55445a395 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseDeactivateParamsTest { + + @Test + fun create() { + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + } + + @Test + fun pathParams() { + val params = LicenseDeactivateParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + + val body = params._body() + + assertThat(body.endDate()).contains(LocalDate.parse("2026-01-27")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = LicenseDeactivateParams.builder().licenseId("license_id").build() + + val body = params._body() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt new file mode 100644 index 000000000..15edeed91 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseDeactivateResponseTest { + + @Test + fun create() { + val licenseDeactivateResponse = + LicenseDeactivateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseDeactivateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseDeactivateResponse.id()).isEqualTo("id") + assertThat(licenseDeactivateResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseDeactivateResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseDeactivateResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseDeactivateResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseDeactivateResponse.status()) + .isEqualTo(LicenseDeactivateResponse.Status.ACTIVE) + assertThat(licenseDeactivateResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseDeactivateResponse = + LicenseDeactivateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseDeactivateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseDeactivateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseDeactivateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseDeactivateResponse).isEqualTo(licenseDeactivateResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt new file mode 100644 index 000000000..4d04e1783 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseExternalLicenseGetUsageParamsTest { + + @Test + fun create() { + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun pathParams() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("external_license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt new file mode 100644 index 000000000..80cf3d8dd --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseExternalLicenseGetUsageResponseTest { + + @Test + fun create() { + val licenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse.builder() + .addData( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseExternalLicenseGetUsageResponse.data()) + .containsExactly( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseExternalLicenseGetUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse.builder() + .addData( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseExternalLicenseGetUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseExternalLicenseGetUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseExternalLicenseGetUsageResponse) + .isEqualTo(licenseExternalLicenseGetUsageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt new file mode 100644 index 000000000..4f9b17d8b --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListPageResponseTest { + + @Test + fun create() { + val licenseListPageResponse = + LicenseListPageResponse.builder() + .addData( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseListPageResponse.data()) + .containsExactly( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + assertThat(licenseListPageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseListPageResponse = + LicenseListPageResponse.builder() + .addData( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseListPageResponse).isEqualTo(licenseListPageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt new file mode 100644 index 000000000..41c62d909 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListParamsTest { + + @Test + fun create() { + LicenseListParams.builder() + .subscriptionId("subscription_id") + .cursor("cursor") + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .limit(1L) + .status(LicenseListParams.Status.ACTIVE) + .build() + } + + @Test + fun queryParams() { + val params = + LicenseListParams.builder() + .subscriptionId("subscription_id") + .cursor("cursor") + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .limit(1L) + .status(LicenseListParams.Status.ACTIVE) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("external_license_id", "external_license_id") + .put("license_type_id", "license_type_id") + .put("limit", "1") + .put("status", "active") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseListParams.builder().subscriptionId("subscription_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("subscription_id", "subscription_id").build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt new file mode 100644 index 000000000..716cdd5b4 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListResponseTest { + + @Test + fun create() { + val licenseListResponse = + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseListResponse.id()).isEqualTo("id") + assertThat(licenseListResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseListResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseListResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseListResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseListResponse.status()).isEqualTo(LicenseListResponse.Status.ACTIVE) + assertThat(licenseListResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseListResponse = + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseListResponse).isEqualTo(licenseListResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt new file mode 100644 index 000000000..a1c636dd4 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveByExternalIdParamsTest { + + @Test + fun create() { + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + } + + @Test + fun pathParams() { + val params = + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("external_license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt new file mode 100644 index 000000000..c9d7e9b26 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveByExternalIdResponseTest { + + @Test + fun create() { + val licenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseRetrieveByExternalIdResponse.id()).isEqualTo("id") + assertThat(licenseRetrieveByExternalIdResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveByExternalIdResponse.externalLicenseId()) + .isEqualTo("external_license_id") + assertThat(licenseRetrieveByExternalIdResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseRetrieveByExternalIdResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveByExternalIdResponse.status()) + .isEqualTo(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + assertThat(licenseRetrieveByExternalIdResponse.subscriptionId()) + .isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseRetrieveByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseRetrieveByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseRetrieveByExternalIdResponse) + .isEqualTo(licenseRetrieveByExternalIdResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt new file mode 100644 index 000000000..c23771812 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveParamsTest { + + @Test + fun create() { + LicenseRetrieveParams.builder().licenseId("license_id").build() + } + + @Test + fun pathParams() { + val params = LicenseRetrieveParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt new file mode 100644 index 000000000..46bc72488 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveResponseTest { + + @Test + fun create() { + val licenseRetrieveResponse = + LicenseRetrieveResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseRetrieveResponse.id()).isEqualTo("id") + assertThat(licenseRetrieveResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseRetrieveResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseRetrieveResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveResponse.status()) + .isEqualTo(LicenseRetrieveResponse.Status.ACTIVE) + assertThat(licenseRetrieveResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseRetrieveResponse = + LicenseRetrieveResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseRetrieveResponse).isEqualTo(licenseRetrieveResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt new file mode 100644 index 000000000..4a11b64bd --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeCreateParamsTest { + + @Test + fun create() { + LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + } + + @Test + fun body() { + val params = + LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + + val body = params._body() + + assertThat(body.groupingKey()).isEqualTo("grouping_key") + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt new file mode 100644 index 000000000..91b78f2bb --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeCreateResponseTest { + + @Test + fun create() { + val licenseTypeCreateResponse = + LicenseTypeCreateResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeCreateResponse.id()).isEqualTo("id") + assertThat(licenseTypeCreateResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeCreateResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeCreateResponse = + LicenseTypeCreateResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeCreateResponse).isEqualTo(licenseTypeCreateResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt new file mode 100644 index 000000000..8462e1fb3 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListPageResponseTest { + + @Test + fun create() { + val licenseTypeListPageResponse = + LicenseTypeListPageResponse.builder() + .addData( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseTypeListPageResponse.data()) + .containsExactly( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + assertThat(licenseTypeListPageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeListPageResponse = + LicenseTypeListPageResponse.builder() + .addData( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseTypeListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeListPageResponse).isEqualTo(licenseTypeListPageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt new file mode 100644 index 000000000..92c42e709 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListParamsTest { + + @Test + fun create() { + LicenseTypeListParams.builder().cursor("cursor").limit(1L).build() + } + + @Test + fun queryParams() { + val params = LicenseTypeListParams.builder().cursor("cursor").limit(1L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "1").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseTypeListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt new file mode 100644 index 000000000..0c5c783eb --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListResponseTest { + + @Test + fun create() { + val licenseTypeListResponse = + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeListResponse.id()).isEqualTo("id") + assertThat(licenseTypeListResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeListResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeListResponse = + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeListResponse).isEqualTo(licenseTypeListResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt new file mode 100644 index 000000000..e1d93b327 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeRetrieveParamsTest { + + @Test + fun create() { + LicenseTypeRetrieveParams.builder().licenseTypeId("license_type_id").build() + } + + @Test + fun pathParams() { + val params = LicenseTypeRetrieveParams.builder().licenseTypeId("license_type_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_type_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt new file mode 100644 index 000000000..8e7235789 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeRetrieveResponseTest { + + @Test + fun create() { + val licenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeRetrieveResponse.id()).isEqualTo("id") + assertThat(licenseTypeRetrieveResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeRetrieveResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeRetrieveResponse).isEqualTo(licenseTypeRetrieveResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt new file mode 100644 index 000000000..d9967a76c --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetAllUsageParamsTest { + + @Test + fun create() { + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun queryParams() { + val params = + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt new file mode 100644 index 000000000..041366f38 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetAllUsageResponseTest { + + @Test + fun create() { + val licenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse.builder() + .addData( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseUsageGetAllUsageResponse.data()) + .containsExactly( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseUsageGetAllUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse.builder() + .addData( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseUsageGetAllUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseUsageGetAllUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseUsageGetAllUsageResponse) + .isEqualTo(licenseUsageGetAllUsageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt new file mode 100644 index 000000000..b14f6766e --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetUsageParamsTest { + + @Test + fun create() { + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun pathParams() { + val params = LicenseUsageGetUsageParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseUsageGetUsageParams.builder().licenseId("license_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt new file mode 100644 index 000000000..19893d26e --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetUsageResponseTest { + + @Test + fun create() { + val licenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse.builder() + .addData( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseUsageGetUsageResponse.data()) + .containsExactly( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseUsageGetUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse.builder() + .addData( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseUsageGetUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseUsageGetUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseUsageGetUsageResponse).isEqualTo(licenseUsageGetUsageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt index 4f47b1738..ab3a67472 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt @@ -47,6 +47,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .paginationMetadata( @@ -87,6 +92,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(metricListPageResponse.paginationMetadata()) @@ -130,6 +140,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .paginationMetadata( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 060ea7c3f..0c63d0bc3 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -421,6 +421,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -500,6 +501,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -584,6 +592,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -663,10 +672,22 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1000,6 +1021,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1105,6 +1127,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1521,6 +1550,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1626,6 +1656,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2149,6 +2186,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2226,6 +2264,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2305,6 +2350,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2382,10 +2428,22 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(mutatedSubscription.redeemedCoupon()) @@ -2704,6 +2762,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2800,6 +2859,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3193,6 +3259,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3289,6 +3356,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3811,6 +3885,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3890,6 +3965,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -3974,6 +4056,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4053,10 +4136,22 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -4390,6 +4485,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4495,6 +4591,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4911,6 +5014,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5016,6 +5120,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt index 951ee45e1..9177eefbf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt @@ -32,6 +32,7 @@ internal class NewAllocationPriceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() @@ -55,6 +56,7 @@ internal class NewAllocationPriceTest { .build() ) assertThat(newAllocationPrice.itemId()).contains("item_id") + assertThat(newAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newAllocationPrice.perUnitCostBasis()).contains("per_unit_cost_basis") } @@ -81,6 +83,7 @@ internal class NewAllocationPriceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt index 45faf3712..e69f6bbd5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -111,6 +112,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingBulkPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingBulkPrice.metadata()) .contains( NewFloatingBulkPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt index 340da8294..950a731be 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt @@ -63,6 +63,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingBulkWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingBulkWithProrationPrice.metadata()) .contains( NewFloatingBulkWithProrationPrice.Metadata.builder() @@ -197,6 +199,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt index 8952c2abc..95778c09c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt @@ -61,6 +61,7 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -131,6 +132,8 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingCumulativeGroupedBulkPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingCumulativeGroupedBulkPrice.metadata()) .contains( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() @@ -191,6 +194,7 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt index 094d0a60f..5b424a3f1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -117,6 +118,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingGroupedAllocationPrice.metadata()) .contains( NewFloatingGroupedAllocationPrice.Metadata.builder() @@ -170,6 +172,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt index 66160bb01..b458fdd74 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingGroupedTieredPackagePrice.metadata()) .contains( NewFloatingGroupedTieredPackagePrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt index 8676809fb..c7d94a269 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingGroupedTieredPrice.metadata()) .contains( NewFloatingGroupedTieredPrice.Metadata.builder() @@ -198,6 +200,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt index c72fd666a..b3e4acb16 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt @@ -76,6 +76,7 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -158,6 +159,8 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedWithMeteredMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingGroupedWithMeteredMinimumPrice.metadata()) .contains( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -233,6 +236,7 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt index 5c5a996cc..16d466ec6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt @@ -58,6 +58,7 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,8 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedWithProratedMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingGroupedWithProratedMinimumPrice.metadata()) .contains( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() @@ -181,6 +184,7 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt index 3f1972cf2..2796b1325 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -125,6 +126,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingMatrixPrice.metadata()) .contains( NewFloatingMatrixPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt index 0755eeb7a..ba8869d67 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt @@ -60,6 +60,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -129,6 +130,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixWithAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingMatrixWithAllocationPrice.metadata()) .contains( NewFloatingMatrixWithAllocationPrice.Metadata.builder() @@ -188,6 +190,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt index a611895a2..21bc3c988 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt @@ -61,6 +61,7 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,8 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixWithDisplayNamePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingMatrixWithDisplayNamePrice.metadata()) .contains( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() @@ -190,6 +193,7 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt index 45b67882e..ae963a1bd 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,8 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMaxGroupTieredPackagePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingMaxGroupTieredPackagePrice.metadata()) .contains( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() @@ -209,6 +212,7 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt index dbd604263..8d249608f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMinimumCompositePrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingMinimumCompositePrice.metadata()) .contains( NewFloatingMinimumCompositePrice.Metadata.builder() @@ -166,6 +168,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt index ed37b52ea..507d11a43 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -107,6 +108,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingPackagePrice.metadata()) .contains( NewFloatingPackagePrice.Metadata.builder() @@ -156,6 +158,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt index ead452761..232023769 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -117,6 +118,8 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingPackageWithAllocationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingPackageWithAllocationPrice.metadata()) .contains( NewFloatingPackageWithAllocationPrice.Metadata.builder() @@ -170,6 +173,7 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt index ff18721f6..379c10ef8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -186,6 +187,8 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingScalableMatrixWithTieredPricingPrice.metadata()) .contains( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -271,6 +274,7 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt index 202827aa1..2a83859f0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt @@ -38,6 +38,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -70,6 +71,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -105,6 +107,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -150,6 +153,8 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingScalableMatrixWithUnitPricingPrice.metadata()) .contains( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -187,6 +192,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -219,6 +225,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt index 848114418..e3361e05c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt @@ -68,6 +68,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -145,6 +146,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingThresholdTotalAmountPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingThresholdTotalAmountPrice.metadata()) .contains( NewFloatingThresholdTotalAmountPrice.Metadata.builder() @@ -212,6 +214,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt index 9c48a9c9e..da537b91c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingTieredPackagePrice.metadata()) .contains( NewFloatingTieredPackagePrice.Metadata.builder() @@ -198,6 +200,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt index 35b3511b3..e371a644a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt @@ -73,6 +73,7 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -152,6 +153,8 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPackageWithMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingTieredPackageWithMinimumPrice.metadata()) .contains( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() @@ -224,6 +227,7 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt index 07ac87b3b..310f7efe7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -125,6 +126,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingTieredPrice.metadata()) .contains( NewFloatingTieredPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt index bd4fdacc9..43be9b6d7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredWithMinimumPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingTieredWithMinimumPrice.metadata()) .contains( NewFloatingTieredWithMinimumPrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt index 1769baf18..6a1f6b3e4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt @@ -58,6 +58,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingTieredWithProrationPrice.metadata()) .contains( NewFloatingTieredWithProrationPrice.Metadata.builder() @@ -181,6 +183,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt index 65938c6f0..b7d43d65c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -101,6 +102,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingUnitPrice.metadata()) .contains( NewFloatingUnitPrice.Metadata.builder() @@ -148,6 +150,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt index 081e00644..20731a8e5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitWithPercentPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingUnitWithPercentPrice.metadata()) .contains( NewFloatingUnitWithPercentPrice.Metadata.builder() @@ -166,6 +168,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt index 2e4fae2ce..8bf8e24f4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -113,6 +114,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingUnitWithProrationPrice.metadata()) .contains( NewFloatingUnitWithProrationPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt index f3f1100a7..f4412d93b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -112,6 +113,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanBulkPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanBulkPrice.metadata()) .contains( NewPlanBulkPrice.Metadata.builder() @@ -166,6 +168,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt index 93f84aaf9..068932a9b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt @@ -63,6 +63,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanBulkWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanBulkWithProrationPrice.metadata()) .contains( NewPlanBulkWithProrationPrice.Metadata.builder() @@ -197,6 +199,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt index 20bd1b583..85970e725 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt @@ -61,6 +61,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -131,6 +132,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanCumulativeGroupedBulkPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanCumulativeGroupedBulkPrice.metadata()) .contains( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() @@ -192,6 +194,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt index 5ce0cab0d..058ae49ce 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanGroupedAllocationPrice.metadata()) .contains( NewPlanGroupedAllocationPrice.Metadata.builder() @@ -170,6 +172,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt index a20e9666f..b126aaae1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -141,6 +142,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanGroupedTieredPackagePrice.metadata()) .contains( NewPlanGroupedTieredPackagePrice.Metadata.builder() @@ -208,6 +210,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt index b3d3e0785..168d14508 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -136,6 +137,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanGroupedTieredPrice.metadata()) .contains( NewPlanGroupedTieredPrice.Metadata.builder() @@ -200,6 +202,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt index f135d9304..149675b40 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt @@ -73,6 +73,7 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -154,6 +155,8 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedWithMeteredMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newPlanGroupedWithMeteredMinimumPrice.metadata()) .contains( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -227,6 +230,7 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt index b237e469b..1557ae707 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt @@ -57,6 +57,7 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -123,6 +124,8 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedWithProratedMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newPlanGroupedWithProratedMinimumPrice.metadata()) .contains( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() @@ -180,6 +183,7 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt index 789bb03b5..aba350850 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMatrixPrice.metadata()) .contains( NewPlanMatrixPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt index 53233108d..ff7218f4b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt @@ -60,6 +60,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -129,6 +130,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixWithAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMatrixWithAllocationPrice.metadata()) .contains( NewPlanMatrixWithAllocationPrice.Metadata.builder() @@ -189,6 +191,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt index 1b1327df7..ea02b00e0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt @@ -60,6 +60,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixWithDisplayNamePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMatrixWithDisplayNamePrice.metadata()) .contains( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() @@ -190,6 +192,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt index 4d3661632..d4806a69e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -142,6 +143,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMaxGroupTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMaxGroupTieredPackagePrice.metadata()) .contains( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt index d35d849ad..70e8a8285 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMinimumCompositePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMinimumCompositePrice.metadata()) .contains( NewPlanMinimumCompositePrice.Metadata.builder() @@ -167,6 +169,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt index 2b8f8db8b..9ed1c967c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -106,6 +107,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanPackagePrice.metadata()) .contains( NewPlanPackagePrice.Metadata.builder() @@ -156,6 +158,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt index 06963f176..24eb1816b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -118,6 +119,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanPackageWithAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanPackageWithAllocationPrice.metadata()) .contains( NewPlanPackageWithAllocationPrice.Metadata.builder() @@ -172,6 +174,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt index 613d5e6f1..9e0c45e2d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -183,6 +184,8 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newPlanScalableMatrixWithTieredPricingPrice.metadata()) .contains( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -270,6 +273,7 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt index 83a3eb800..5634a05f8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt @@ -36,6 +36,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -69,6 +70,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -102,6 +104,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -148,6 +151,8 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newPlanScalableMatrixWithUnitPricingPrice.metadata()) .contains( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -184,6 +189,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -217,6 +223,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt index 90357304e..47c496502 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt @@ -68,6 +68,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanThresholdTotalAmountPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanThresholdTotalAmountPrice.metadata()) .contains( NewPlanThresholdTotalAmountPrice.Metadata.builder() @@ -211,6 +213,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt index 35759c36d..e531bd65e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -136,6 +137,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanTieredPackagePrice.metadata()) .contains( NewPlanTieredPackagePrice.Metadata.builder() @@ -200,6 +202,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt index 7fad794b9..a5cb898d1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt @@ -70,6 +70,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPackageWithMinimumPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanTieredPackageWithMinimumPrice.metadata()) .contains( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() @@ -218,6 +220,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt index 5176465f5..f220a5660 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanTieredPrice.metadata()) .contains( NewPlanTieredPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt index 9cae1ad69..79e3574ed 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -142,6 +143,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredWithMinimumPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanTieredWithMinimumPrice.metadata()) .contains( NewPlanTieredWithMinimumPrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt index e3a650dc8..59beb2607 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -102,6 +103,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanUnitPrice.metadata()) .contains( NewPlanUnitPrice.Metadata.builder() @@ -150,6 +152,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt index 0b4d1f7b0..c6bd0c867 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitWithPercentPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanUnitWithPercentPrice.metadata()) .contains( NewPlanUnitWithPercentPrice.Metadata.builder() @@ -167,6 +169,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt index 0325b3841..dfa16f991 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -112,6 +113,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanUnitWithProrationPrice.metadata()) .contains( NewPlanUnitWithProrationPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt index 6dded0f58..94d6cf4f7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionBulkPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionBulkPrice.metadata()) .contains( NewSubscriptionBulkPrice.Metadata.builder() @@ -168,6 +170,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt index 86c0346bf..9fcd36023 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt @@ -65,6 +65,7 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,8 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionBulkWithProrationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionBulkWithProrationPrice.metadata()) .contains( NewSubscriptionBulkWithProrationPrice.Metadata.builder() @@ -203,6 +206,7 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt index d04f7ee3d..00bbe9835 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt @@ -63,6 +63,7 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,8 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionCumulativeGroupedBulkPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionCumulativeGroupedBulkPrice.metadata()) .contains( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() @@ -197,6 +200,7 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt index 2bad026b8..3a8de1294 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -118,6 +119,8 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedAllocationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionGroupedAllocationPrice.metadata()) .contains( NewSubscriptionGroupedAllocationPrice.Metadata.builder() @@ -172,6 +175,7 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt index 35e111782..a7b756233 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt @@ -69,6 +69,7 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -146,6 +147,8 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedTieredPackagePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionGroupedTieredPackagePrice.metadata()) .contains( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() @@ -215,6 +218,7 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt index d74b508a1..7f649a4d4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionGroupedTieredPrice.metadata()) .contains( NewSubscriptionGroupedTieredPrice.Metadata.builder() @@ -202,6 +204,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt index 122ebb77b..f1aef9d49 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt @@ -77,6 +77,7 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -163,6 +164,8 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.metadata()) .contains( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -241,6 +244,7 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt index f82dd1066..64476d695 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt @@ -58,6 +58,7 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,8 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedWithProratedMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionGroupedWithProratedMinimumPrice.metadata()) .contains( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() @@ -189,6 +192,7 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt index 2c6dac335..5297a855d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -126,6 +127,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionMatrixPrice.metadata()) .contains( NewSubscriptionMatrixPrice.Metadata.builder() @@ -185,6 +187,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt index 5ac3dfef8..1d8c78066 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt @@ -62,6 +62,7 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -132,6 +133,8 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixWithAllocationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionMatrixWithAllocationPrice.metadata()) .contains( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() @@ -194,6 +197,7 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt index 6ed09c6ac..b21dbdf5b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt @@ -63,6 +63,7 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,8 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixWithDisplayNamePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionMatrixWithDisplayNamePrice.metadata()) .contains( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() @@ -197,6 +200,7 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt index 4ebf6136c..c1ac1e30b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt @@ -71,6 +71,7 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,8 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMaxGroupTieredPackagePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionMaxGroupTieredPackagePrice.metadata()) .contains( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() @@ -219,6 +222,7 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt index 19dedc47c..8bfeabc78 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,7 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMinimumCompositePrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionMinimumCompositePrice.metadata()) .contains( NewSubscriptionMinimumCompositePrice.Metadata.builder() @@ -169,6 +171,7 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt index 169262636..291135cba 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -108,6 +109,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionPackagePrice.metadata()) .contains( NewSubscriptionPackagePrice.Metadata.builder() @@ -158,6 +160,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt index 0a6d6087b..3b813e67b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt @@ -56,6 +56,7 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -120,6 +121,8 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionPackageWithAllocationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionPackageWithAllocationPrice.metadata()) .contains( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() @@ -176,6 +179,7 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt index ddc357025..fedd9901e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -196,6 +197,8 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.metadata()) .contains( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -283,6 +286,7 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt index 312ab4b27..b3f2eef1e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt @@ -37,6 +37,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -70,6 +71,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -107,6 +109,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -159,6 +162,8 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.metadata()) .contains( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -197,6 +202,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -230,6 +236,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt index d002d94c0..9198891c6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt @@ -70,6 +70,7 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,8 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionThresholdTotalAmountPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionThresholdTotalAmountPrice.metadata()) .contains( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() @@ -218,6 +221,7 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt index 0357b6191..c523914c8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionTieredPackagePrice.metadata()) .contains( NewSubscriptionTieredPackagePrice.Metadata.builder() @@ -202,6 +204,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt index 110d066f6..c9dc66e10 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt @@ -76,6 +76,7 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -159,6 +160,8 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPackageWithMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionTieredPackageWithMinimumPrice.metadata()) .contains( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() @@ -236,6 +239,7 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt index 5260ed9e8..f387450e8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -126,6 +127,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionTieredPrice.metadata()) .contains( NewSubscriptionTieredPrice.Metadata.builder() @@ -185,6 +187,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt index 822033076..cdfe808c6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt @@ -69,6 +69,7 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -146,6 +147,8 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredWithMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionTieredWithMinimumPrice.metadata()) .contains( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() @@ -215,6 +218,7 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt index d9a6fe54d..39d8a9449 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -104,6 +105,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionUnitPrice.metadata()) .contains( NewSubscriptionUnitPrice.Metadata.builder() @@ -152,6 +154,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt index dee30f504..20dc58ccf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitWithPercentPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionUnitWithPercentPrice.metadata()) .contains( NewSubscriptionUnitWithPercentPrice.Metadata.builder() @@ -169,6 +171,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt index 9dd1ce78d..1d19980ea 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,8 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitWithProrationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionUnitWithProrationPrice.metadata()) .contains( NewSubscriptionUnitWithProrationPrice.Metadata.builder() @@ -166,6 +169,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 210a3f813..25066561a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -56,6 +56,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -130,6 +131,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -181,6 +189,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -255,6 +264,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -310,6 +326,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -384,6 +401,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index c4bbae5ee..5edaf24c8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -36,9 +36,72 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence.ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -83,6 +146,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -169,9 +233,76 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -218,6 +349,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -302,9 +434,72 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence.ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -349,6 +544,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt index f88092a24..749c61a5f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanListPageResponseTest.kt @@ -210,6 +210,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -289,6 +290,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -502,6 +510,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -579,6 +588,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -802,6 +818,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -881,6 +898,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt index 851d4c480..36dc533e7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanTest.kt @@ -198,6 +198,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -272,6 +273,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -486,6 +494,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -560,6 +569,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -769,6 +785,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -843,6 +860,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index be7ed5eff..98a4f5fc5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -89,6 +89,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -163,6 +164,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .version(0L) @@ -248,6 +256,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -322,6 +331,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -406,6 +422,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -480,6 +497,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .version(0L) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt index 4f4e9b97c..21470db42 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt @@ -49,6 +49,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -103,6 +104,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -156,6 +158,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt index eb10246d1..148355434 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt @@ -22,6 +22,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -65,6 +71,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -91,6 +98,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -136,6 +149,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -161,6 +175,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -204,6 +224,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt index c017f5856..e41ef0c44 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.JsonValue import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -19,6 +20,11 @@ internal class PriceEvaluateParamsTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() } @@ -47,6 +53,11 @@ internal class PriceEvaluateParamsTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val body = params._body() @@ -60,6 +71,12 @@ internal class PriceEvaluateParamsTest { .contains("my_numeric_property > 100 AND my_other_property = 'bar'") assertThat(body.groupingKeys().getOrNull()) .containsExactly("case when my_event_type = 'foo' then true else false end") + assertThat(body.metricParameterOverrides()) + .contains( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt index 40a74d21f..9133061a5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt @@ -35,6 +35,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -78,6 +84,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -117,6 +124,13 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -162,6 +176,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -201,6 +216,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -244,6 +265,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 91f34c657..a1556ff9e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -71,6 +71,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -145,10 +146,22 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() assertThat(priceInterval.id()).isEqualTo("id") @@ -212,6 +225,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -286,12 +300,25 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) assertThat(priceInterval.startDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(priceInterval.usageCustomerIds().getOrNull()).containsExactly("string") + assertThat(priceInterval.metricParameterOverrides()) + .contains( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test @@ -354,6 +381,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -428,10 +456,22 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val roundtrippedPriceInterval = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt index adcd2fae7..65d4d7789 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceListPageResponseTest.kt @@ -56,6 +56,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -130,6 +131,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .paginationMetadata( @@ -180,6 +188,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -254,6 +263,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -307,6 +323,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -381,6 +398,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .paginationMetadata( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt index 158dacf8c..daaa79de6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceTest.kt @@ -58,6 +58,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -130,6 +131,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofUnit(unit) @@ -212,6 +220,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -286,6 +295,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -338,6 +354,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -421,6 +438,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Tiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTiered(tiered) @@ -503,6 +527,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -586,6 +611,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Tiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -645,6 +677,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -716,6 +749,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Bulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofBulk(bulk) @@ -808,6 +848,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -879,6 +920,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Bulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -953,6 +1001,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1024,6 +1073,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithFilters.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofBulkWithFilters(bulkWithFilters) @@ -1128,6 +1184,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1199,6 +1256,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithFilters.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1251,6 +1315,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1325,6 +1390,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Package.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPackage(package_) @@ -1407,6 +1479,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1484,6 +1557,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Package.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1536,6 +1616,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1619,6 +1700,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Matrix.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMatrix(matrix) @@ -1701,6 +1789,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1784,6 +1873,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Matrix.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1836,6 +1932,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1926,6 +2023,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ThresholdTotalAmount.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) @@ -2010,6 +2114,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2102,6 +2207,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ThresholdTotalAmount.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2154,6 +2266,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2242,6 +2355,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredPackage(tieredPackage) @@ -2324,6 +2444,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2412,6 +2533,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2464,6 +2592,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2555,6 +2684,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredWithMinimum(tieredWithMinimum) @@ -2639,6 +2775,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2730,6 +2867,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2782,6 +2926,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2870,6 +3015,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedTiered(groupedTiered) @@ -2952,6 +3104,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3040,6 +3193,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3094,6 +3254,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3186,6 +3347,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackageWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) @@ -3273,6 +3441,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3365,6 +3534,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackageWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3419,6 +3595,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3497,6 +3674,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.PackageWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPackageWithAllocation(packageWithAllocation) @@ -3581,6 +3765,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3659,6 +3844,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.PackageWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3711,6 +3903,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3788,6 +3981,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithPercent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofUnitWithPercent(unitWithPercent) @@ -3870,6 +4070,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3947,6 +4148,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithPercent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3999,6 +4207,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4083,6 +4292,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMatrixWithAllocation(matrixWithAllocation) @@ -4167,6 +4383,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4251,6 +4468,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4303,6 +4527,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4384,6 +4609,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredWithProration(tieredWithProration) @@ -4468,6 +4700,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4549,6 +4782,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4601,6 +4841,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4677,6 +4918,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofUnitWithProration(unitWithProration) @@ -4761,6 +5009,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4837,6 +5086,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4889,6 +5145,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4967,6 +5224,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedAllocation(groupedAllocation) @@ -5051,6 +5315,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5129,6 +5394,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5197,6 +5469,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5268,6 +5541,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofBulkWithProration(bulkWithProration) @@ -5368,6 +5648,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5439,6 +5720,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5493,6 +5781,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5571,6 +5860,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithProratedMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) @@ -5658,6 +5954,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5736,6 +6033,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithProratedMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5790,6 +6094,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5885,6 +6190,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMeteredMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) @@ -5972,6 +6284,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6067,6 +6380,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMeteredMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6123,6 +6443,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6202,6 +6523,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMinMaxThresholds.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) @@ -6290,6 +6618,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6370,6 +6699,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMinMaxThresholds.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6424,6 +6760,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6508,6 +6845,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithDisplayName.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) @@ -6592,6 +6936,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6676,6 +7021,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithDisplayName.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6728,6 +7080,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6817,6 +7170,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedTieredPackage(groupedTieredPackage) @@ -6901,6 +7261,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6990,6 +7351,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7044,6 +7412,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7133,6 +7502,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MaxGroupTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) @@ -7217,6 +7593,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7308,6 +7685,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MaxGroupTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7365,6 +7749,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7444,6 +7829,7 @@ internal class PriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -7454,6 +7840,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ScalableMatrixWithUnitPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) @@ -7542,6 +7935,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7622,6 +8016,7 @@ internal class PriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -7632,6 +8027,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ScalableMatrixWithUnitPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7690,6 +8092,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7796,6 +8199,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ScalableMatrixWithTieredPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) @@ -7885,6 +8295,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7991,6 +8402,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ScalableMatrixWithTieredPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8045,6 +8463,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .cumulativeGroupedBulkConfig( @@ -8129,6 +8548,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedBulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) @@ -8213,6 +8639,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .cumulativeGroupedBulkConfig( @@ -8298,6 +8725,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedBulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8354,6 +8788,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .cumulativeGroupedAllocationConfig( @@ -8433,6 +8868,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation) @@ -8521,6 +8963,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .cumulativeGroupedAllocationConfig( @@ -8601,6 +9044,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8653,6 +9103,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8730,6 +9181,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MinimumComposite.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMinimumComposite(minimumComposite) @@ -8812,6 +9270,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8889,6 +9348,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MinimumComposite.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8941,6 +9407,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9013,6 +9480,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Percent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPercent(percent) @@ -9095,6 +9569,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9167,6 +9642,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Percent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -9219,6 +9701,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9297,6 +9780,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.EventOutput.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofEventOutput(eventOutput) @@ -9379,6 +9869,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9457,6 +9948,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.EventOutput.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt index 0f2cac109..5a07ae864 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeApplyResponseTest.kt @@ -461,6 +461,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -552,6 +553,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +658,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -741,10 +750,22 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1132,6 +1153,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1255,6 +1277,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1775,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1869,6 +1899,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2438,6 +2475,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2521,6 +2559,13 @@ internal class SubscriptionChangeApplyResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2655,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2693,10 +2739,22 @@ internal class SubscriptionChangeApplyResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -3056,6 +3114,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3172,6 +3231,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3691,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3741,6 +3808,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4329,6 +4403,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4420,6 +4495,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4600,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4609,10 +4692,22 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -5000,6 +5095,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5123,6 +5219,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5717,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5737,6 +5841,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt index f495f5643..3ba7045a1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeCancelResponseTest.kt @@ -461,6 +461,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -552,6 +553,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +658,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -741,10 +750,22 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1132,6 +1153,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1255,6 +1277,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1775,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1869,6 +1899,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2438,6 +2475,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2521,6 +2559,13 @@ internal class SubscriptionChangeCancelResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2655,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2693,10 +2739,22 @@ internal class SubscriptionChangeCancelResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -3056,6 +3114,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3172,6 +3231,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3691,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3741,6 +3808,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4329,6 +4403,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4420,6 +4495,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4600,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4609,10 +4692,22 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -5000,6 +5095,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5123,6 +5219,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5717,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5737,6 +5841,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt index 5254d6977..599ac44e7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionChangeRetrieveResponseTest.kt @@ -461,6 +461,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -552,6 +553,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +658,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -741,10 +750,22 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1132,6 +1153,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1255,6 +1277,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1775,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1869,6 +1899,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2438,6 +2475,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2521,6 +2559,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2655,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2693,10 +2739,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -3056,6 +3114,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3172,6 +3231,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3691,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3741,6 +3808,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4329,6 +4403,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4420,6 +4495,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4600,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4609,10 +4692,22 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -5000,6 +5095,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5123,6 +5219,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5717,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5737,6 +5841,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index fa2ac6848..4d80872c9 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -65,6 +65,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -79,6 +80,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -124,6 +130,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -228,6 +235,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -242,6 +250,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -286,6 +299,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -359,6 +373,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -373,6 +388,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -420,6 +440,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -524,6 +545,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -538,6 +560,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -584,6 +611,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -656,6 +684,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -670,6 +699,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -715,6 +749,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -826,6 +861,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -840,6 +876,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -884,6 +925,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index 0ae21fa3e..b10c24d7e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt @@ -76,6 +76,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -167,6 +168,13 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +246,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -321,6 +330,13 @@ internal class SubscriptionFetchCostsResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +419,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -494,6 +511,13 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 4494ff91e..935329164 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt @@ -37,6 +37,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -52,6 +53,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -96,6 +102,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -152,6 +159,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() @@ -204,6 +216,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -220,6 +233,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -266,6 +284,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -323,6 +342,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() @@ -362,6 +386,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -377,6 +402,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -421,6 +451,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -479,6 +510,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index c39d53054..e794907f8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -67,6 +67,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -81,6 +82,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -126,6 +133,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -221,6 +229,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -235,6 +244,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -279,6 +294,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -366,6 +382,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -380,6 +397,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -427,6 +450,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -522,6 +546,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -536,6 +561,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -582,6 +614,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -655,6 +688,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -669,6 +703,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -714,6 +754,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -812,6 +853,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -826,6 +868,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -870,6 +918,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index decfe4eee..f5f2119b7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt @@ -421,6 +421,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -500,6 +501,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -584,6 +592,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -663,10 +672,22 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1093,6 +1114,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1170,6 +1192,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1249,6 +1278,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1326,10 +1356,22 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(subscription.redeemedCoupon()) @@ -1762,6 +1804,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1841,6 +1884,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1925,6 +1975,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2004,10 +2055,22 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt index 93ca1b208..b42ac5aa4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsTest.kt @@ -457,6 +457,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -548,6 +549,13 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -646,6 +654,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -737,10 +746,22 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1187,6 +1208,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1270,6 +1292,13 @@ internal class SubscriptionsTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1359,6 +1388,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1442,10 +1472,22 @@ internal class SubscriptionsTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1915,6 +1957,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2006,6 +2049,13 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2104,6 +2154,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2195,10 +2246,22 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt index d1dc0d04a..4802ed450 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt @@ -131,7 +131,9 @@ internal class AlertServiceAsyncTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .pricingUnitId("pricing_unit_id") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index 0093f1b67..7a55dc441 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -88,9 +88,86 @@ internal class BetaServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -141,6 +218,7 @@ internal class BetaServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,9 +295,89 @@ internal class BetaServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -270,6 +428,7 @@ internal class BetaServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt index 61350631a..c58df3b7b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt @@ -38,4 +38,19 @@ internal class CreditBlockServiceAsyncTest { val response = future.get() } + + @Test + fun listInvoices() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val creditBlockServiceAsync = client.creditBlocks() + + val responseFuture = creditBlockServiceAsync.listInvoices("block_id") + + val response = responseFuture.get() + response.validate() + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index 636faaff3..744a924ed 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt @@ -9,6 +9,7 @@ import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceDeleteLineItemParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams import com.withorb.api.models.InvoiceMarkPaidParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount @@ -51,6 +52,7 @@ internal class InvoiceServiceAsyncTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -98,6 +100,7 @@ internal class InvoiceServiceAsyncTest { invoiceServiceAsync.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -199,6 +202,27 @@ internal class InvoiceServiceAsyncTest { invoice.validate() } + @Test + fun issueSummary() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val invoiceServiceAsync = client.invoices() + + val responseFuture = + invoiceServiceAsync.issueSummary( + InvoiceIssueSummaryParams.builder() + .invoiceId("invoice_id") + .synchronous(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Test fun listSummary() { val client = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt new file mode 100644 index 000000000..b620e553e --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseServiceAsyncTest { + + @Test + fun create() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val licenseFuture = + licenseServiceAsync.create( + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + ) + + val license = licenseFuture.get() + license.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val licenseFuture = licenseServiceAsync.retrieve("license_id") + + val license = licenseFuture.get() + license.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val pageFuture = + licenseServiceAsync.list( + LicenseListParams.builder().subscriptionId("subscription_id").build() + ) + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun deactivate() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val responseFuture = + licenseServiceAsync.deactivate( + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Test + fun retrieveByExternalId() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val responseFuture = + licenseServiceAsync.retrieveByExternalId( + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt new file mode 100644 index 000000000..03ca7cf52 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseTypeCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseTypeServiceAsyncTest { + + @Test + fun create() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val licenseTypeFuture = + licenseTypeServiceAsync.create( + LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + ) + + val licenseType = licenseTypeFuture.get() + licenseType.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val licenseTypeFuture = licenseTypeServiceAsync.retrieve("license_type_id") + + val licenseType = licenseTypeFuture.get() + licenseType.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val pageFuture = licenseTypeServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index 709bba422..e0f7d9337 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -57,9 +57,80 @@ internal class PlanServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -110,6 +181,7 @@ internal class PlanServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index 2738e47c1..30385ba2a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt @@ -9,7 +9,6 @@ import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewFloatingUnitPrice -import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluatePreviewEventsParams @@ -33,55 +32,47 @@ internal class PriceServiceAsyncTest { val priceFuture = priceServiceAsync.create( - PriceCreateParams.builder() - .body( - NewFloatingUnitPrice.builder() - .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingUnitPrice.ModelType.UNIT) - .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .prorated(true) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId( - "external_dimensional_price_group_id" - ) - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingUnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) + NewFloatingUnitPrice.builder() + .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) + .currency("currency") + .itemId("item_id") + .modelType(NewFloatingUnitPrice.ModelType.UNIT) + .name("Annual fee") + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + NewFloatingUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .build() @@ -150,6 +141,11 @@ internal class PriceServiceAsyncTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) @@ -180,6 +176,12 @@ internal class PriceServiceAsyncTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -229,6 +231,7 @@ internal class PriceServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -282,6 +285,13 @@ internal class PriceServiceAsyncTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -331,6 +341,7 @@ internal class PriceServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 513e0f995..6c0011c60 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt @@ -103,6 +103,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -117,6 +118,11 @@ internal class SubscriptionServiceAsyncTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -168,6 +174,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -274,6 +281,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -288,6 +296,12 @@ internal class SubscriptionServiceAsyncTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -338,6 +352,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -548,6 +563,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -564,6 +580,12 @@ internal class SubscriptionServiceAsyncTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -614,6 +636,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -673,6 +696,12 @@ internal class SubscriptionServiceAsyncTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() @@ -784,6 +813,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -798,6 +828,13 @@ internal class SubscriptionServiceAsyncTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -849,6 +886,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -946,6 +984,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -960,6 +999,13 @@ internal class SubscriptionServiceAsyncTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -1010,6 +1056,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 304861b85..f607bd439 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -88,9 +88,91 @@ internal class ExternalPlanIdServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -141,6 +223,7 @@ internal class ExternalPlanIdServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,9 +300,91 @@ internal class ExternalPlanIdServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -270,6 +435,7 @@ internal class ExternalPlanIdServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt index 8fffa8b4e..b6c3884c8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt @@ -73,6 +73,7 @@ internal class LedgerServiceAsyncTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -143,6 +144,7 @@ internal class LedgerServiceAsyncTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt new file mode 100644 index 000000000..445726bb1 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExternalLicenseServiceAsyncTest { + + @Test + fun getUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val externalLicenseServiceAsync = client.licenses().externalLicenses() + + val responseFuture = + externalLicenseServiceAsync.getUsage( + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt new file mode 100644 index 000000000..72f120b68 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageServiceAsyncTest { + + @Test + fun getAllUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageServiceAsync = client.licenses().usage() + + val responseFuture = + usageServiceAsync.getAllUsage( + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Test + fun getUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageServiceAsync = client.licenses().usage() + + val responseFuture = + usageServiceAsync.getUsage( + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt index 9ab70abdb..a00d25b96 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt @@ -126,7 +126,9 @@ internal class AlertServiceTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .pricingUnitId("pricing_unit_id") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index 7f538b370..e8df9de9e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -88,9 +88,86 @@ internal class BetaServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -141,6 +218,7 @@ internal class BetaServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,9 +295,89 @@ internal class BetaServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.Unit + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -270,6 +428,7 @@ internal class BetaServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt index b52247712..9e7a7b279 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt @@ -35,4 +35,18 @@ internal class CreditBlockServiceTest { creditBlockService.delete("block_id") } + + @Test + fun listInvoices() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val creditBlockService = client.creditBlocks() + + val response = creditBlockService.listInvoices("block_id") + + response.validate() + } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 5a0c09455..b10acbfff 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt @@ -9,6 +9,7 @@ import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceDeleteLineItemParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams import com.withorb.api.models.InvoiceMarkPaidParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount @@ -51,6 +52,7 @@ internal class InvoiceServiceTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -97,6 +99,7 @@ internal class InvoiceServiceTest { invoiceService.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -190,6 +193,26 @@ internal class InvoiceServiceTest { invoice.validate() } + @Test + fun issueSummary() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val invoiceService = client.invoices() + + val response = + invoiceService.issueSummary( + InvoiceIssueSummaryParams.builder() + .invoiceId("invoice_id") + .synchronous(true) + .build() + ) + + response.validate() + } + @Test fun listSummary() { val client = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt new file mode 100644 index 000000000..739be45b4 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseServiceTest { + + @Test + fun create() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val license = + licenseService.create( + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + ) + + license.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val license = licenseService.retrieve("license_id") + + license.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val page = + licenseService.list( + LicenseListParams.builder().subscriptionId("subscription_id").build() + ) + + page.response().validate() + } + + @Test + fun deactivate() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val response = + licenseService.deactivate( + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + ) + + response.validate() + } + + @Test + fun retrieveByExternalId() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val response = + licenseService.retrieveByExternalId( + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + ) + + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt new file mode 100644 index 000000000..e86dcf903 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseTypeCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseTypeServiceTest { + + @Test + fun create() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val licenseType = + licenseTypeService.create( + LicenseTypeCreateParams.builder().groupingKey("grouping_key").name("name").build() + ) + + licenseType.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val licenseType = licenseTypeService.retrieve("license_type_id") + + licenseType.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val page = licenseTypeService.list() + + page.response().validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index 62e6a8a4e..afc6d6962 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -57,9 +57,80 @@ internal class PlanServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Unit.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -110,6 +181,7 @@ internal class PlanServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index de3c5a9ae..38342a961 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt @@ -9,7 +9,6 @@ import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewFloatingUnitPrice -import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluatePreviewEventsParams @@ -33,55 +32,47 @@ internal class PriceServiceTest { val price = priceService.create( - PriceCreateParams.builder() - .body( - NewFloatingUnitPrice.builder() - .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingUnitPrice.ModelType.UNIT) - .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .prorated(true) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId( - "external_dimensional_price_group_id" - ) - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingUnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) + NewFloatingUnitPrice.builder() + .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) + .currency("currency") + .itemId("item_id") + .modelType(NewFloatingUnitPrice.ModelType.UNIT) + .name("Annual fee") + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + NewFloatingUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .build() @@ -147,6 +138,11 @@ internal class PriceServiceTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) @@ -176,6 +172,12 @@ internal class PriceServiceTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -225,6 +227,7 @@ internal class PriceServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -277,6 +280,13 @@ internal class PriceServiceTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -326,6 +336,7 @@ internal class PriceServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 457bb6fcd..96de618eb 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt @@ -103,6 +103,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -117,6 +118,11 @@ internal class SubscriptionServiceTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -168,6 +174,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -274,6 +281,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -288,6 +296,12 @@ internal class SubscriptionServiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -338,6 +352,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -540,6 +555,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -556,6 +572,12 @@ internal class SubscriptionServiceTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -606,6 +628,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -665,6 +688,12 @@ internal class SubscriptionServiceTest { .quantity(5L) .build() ) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") .build() @@ -774,6 +803,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -788,6 +818,13 @@ internal class SubscriptionServiceTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -839,6 +876,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -936,6 +974,7 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -950,6 +989,13 @@ internal class SubscriptionServiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -1000,6 +1046,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index 961704179..07969a8ea 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -88,9 +88,91 @@ internal class ExternalPlanIdServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -141,6 +223,7 @@ internal class ExternalPlanIdServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,9 +300,91 @@ internal class ExternalPlanIdServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Unit + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -270,6 +435,7 @@ internal class ExternalPlanIdServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt index 3db03f154..ded8e622d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt @@ -72,6 +72,7 @@ internal class LedgerServiceTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -141,6 +142,7 @@ internal class LedgerServiceTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt new file mode 100644 index 000000000..3bb995d17 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExternalLicenseServiceTest { + + @Test + fun getUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val externalLicenseService = client.licenses().externalLicenses() + + val response = + externalLicenseService.getUsage( + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt new file mode 100644 index 000000000..34ec9d205 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageServiceTest { + + @Test + fun getAllUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageService = client.licenses().usage() + + val response = + usageService.getAllUsage( + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } + + @Test + fun getUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageService = client.licenses().usage() + + val response = + usageService.getUsage( + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } +} diff --git a/orb-java-example/build.gradle.kts b/orb-java-example/build.gradle.kts index 3e7cb2236..818cd7587 100644 --- a/orb-java-example/build.gradle.kts +++ b/orb-java-example/build.gradle.kts @@ -8,7 +8,8 @@ repositories { } dependencies { - implementation(project(":orb-java")) + implementation(project(":orb-java-core")) + implementation(project(":orb-java-client-okhttp")) } tasks.withType().configureEach { diff --git a/orb-java-proguard-test/build.gradle.kts b/orb-java-proguard-test/build.gradle.kts index a738f0f3e..e68c59a0b 100644 --- a/orb-java-proguard-test/build.gradle.kts +++ b/orb-java-proguard-test/build.gradle.kts @@ -18,7 +18,7 @@ dependencies { testImplementation(project(":orb-java")) testImplementation(kotlin("test")) testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } diff --git a/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt b/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt index ce15e3f90..55b06b366 100644 --- a/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt +++ b/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt @@ -68,6 +68,8 @@ internal class ProGuardCompatibilityTest { assertThat(client.dimensionalPriceGroups()).isNotNull() assertThat(client.subscriptionChanges()).isNotNull() assertThat(client.creditBlocks()).isNotNull() + assertThat(client.licenseTypes()).isNotNull() + assertThat(client.licenses()).isNotNull() } @Test diff --git a/scripts/build b/scripts/build index f40634826..16a2b00db 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Building classes" -./gradlew build testClasses -x test +./gradlew build testClasses "$@" -x test diff --git a/scripts/mock b/scripts/mock index 0b28f6ea2..bcf3b392b 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then + # Pre-install the package so the download doesn't eat into the startup timeout + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - # Wait for server to come online + # Wait for server to come online (max 30s) echo -n "Waiting for server" + attempts=0 while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + attempts=$((attempts + 1)) + if [ "$attempts" -ge 300 ]; then + echo + echo "Timed out waiting for Prism server to start" + cat .prism.log + exit 1 + fi echo -n "." sleep 0.1 done diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts index 548d15272..10f3c7055 100755 --- a/scripts/upload-artifacts +++ b/scripts/upload-artifacts @@ -96,8 +96,52 @@ generate_instructions() {

Stainless SDK Maven Repository

This is the Maven repository for your Stainless Java SDK build.

-

Directions

-

To use the uploaded Maven repository, add the following to your project's pom.xml:

+

Project configuration

+ +

The details depend on whether you're using Maven or Gradle as your build tool.

+ +

Maven

+ +

Add the following to your project's pom.xml:

+
<repositories>
+    <repository>
+        <id>stainless-sdk-repo</id>
+        <url>https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn</url>
+    </repository>
+</repositories>
+ +

Gradle

+

Add the following to your build.gradle file:

+
repositories {
+    maven {
+        url "https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn"
+    }
+}
+ +
+

Configuring authentication (if required)

+ +

Some accounts may require authentication to access the repository. If so, use the + following instructions, replacing YOUR_STAINLESS_API_TOKEN with your actual token.

+ +

Maven with authentication

+ +

First, ensure you have the following in your Maven settings.xml for repo authentication:

+
<servers>
+    <server>
+        <id>stainless-sdk-repo</id>
+        <configuration>
+            <httpHeaders>
+                <property>
+                    <name>Authorization</name>
+                    <value>Bearer YOUR_STAINLESS_API_TOKEN</value>
+                </property>
+            </httpHeaders>
+        </configuration>
+    </server>
+</servers>
+ +

Then, add the following to your project's pom.xml:

<repositories>
     <repository>
         <id>stainless-sdk-repo</id>
@@ -105,14 +149,24 @@ generate_instructions() {
     </repository>
 </repositories>
-

If you're using Gradle, add the following to your build.gradle file:

+

Gradle with authentication

+

Add the following to your build.gradle file:

repositories {
     maven {
-        url 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'
+        url "https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn"
+        credentials(HttpHeaderCredentials) {
+            name = "Authorization"
+            value = "Bearer YOUR_STAINLESS_API_TOKEN"
+        }
+        authentication {
+            header(HttpHeaderAuthentication)
+        }
     }
 }
+
-

Once you've added the repository, you can include dependencies from it as usual. See your +

Using the repository

+

Once you've configured the repository, you can include dependencies from it as usual. See your project README for more details.